Welcome to Dream.In.Code
Getting Help is Easy!

Join 131,771 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,141 people online right now. Registration is fast and FREE... Join Now!




Access - Parameter Passing

 
Reply to this topicStart new topic

Access - Parameter Passing

Limbo
post 8 Oct, 2008 - 05:14 AM
Post #1


D.I.C Head

**
Joined: 8 Mar, 2006
Posts: 133


My Contributions


Is there a way to designate a global variable in Access?

I have a data entry form and am trying to run a query with the value entered on a combo box on the form.
Alternatively, I tried running the SQL code in VB, but I get an error - cannot find input table. The form is not 'recordsource' to this table, and the query is a Make-Table query (from the Master table to the Temp Table). The form's recordsource is the temp table.

CODE

Private Sub Extract()
DoCmd.RunSQL "SELECT [Pkg_Estimate].[Pkg_No], [Pkg_Estimate].[Date_Rcvd], [Pkg_Estimate].[Comments] INTO Est_Pkg" & _
" FROM [Pkg_Estimate]" & _
"WHERE ([Pkg_Estimate].Pkg_No)= '" & cmbpkglist.Value & "';"
End Sub


Any suggestions on how to pass the parameter in combo box cmbpkglist?
User is offlineProfile CardPM

Go to the top of the page

Limbo
post 8 Oct, 2008 - 11:31 AM
Post #2


D.I.C Head

**
Joined: 8 Mar, 2006
Posts: 133


My Contributions


Well, I kinda figured how to do this, but I'm still running into a problem.

In the query, I set as Criteria "[Forms]![Package]![cmbpkglist]" and I defined the parameter.
I'm assuming its running through ok, but they Query is make table query and it's only always adding 0 rows.

I made sure that the form and it's entities are unbounded.

CODE

PARAMETERS Forms!Package_Estimate!cmbpkglist Text ( 255 );
SELECT [Pkg_ Estimate].Pkg_No, [Pkg_ Estimate].Date_Rcvd, [Pkg_ Estimate].Comments INTO Est_Pkg
FROM [Pkg_ Estimate]
WHERE ((([Pkg_ Estimate].Pkg_No)=[Forms]![Package_Estimate]![cmbpkglist]))


Anything I'm doing wrong.
I open the query on cmbpkglist_Exit()
User is offlineProfile CardPM

Go to the top of the page

Limbo
post 8 Oct, 2008 - 02:30 PM
Post #3


D.I.C Head

**
Joined: 8 Mar, 2006
Posts: 133


My Contributions


It was actually some focus issue. I think i figured it out.
I made commandbutton to simplify things.
The way my form was set up- tabular form. The criteria was in the header section, but setfocus was in the detail section... still a bit buggy, but it works sometimes

This post has been edited by Limbo: 8 Oct, 2008 - 02:30 PM
User is offlineProfile CardPM

Go to the top of the page

dlkirk03
post 9 Oct, 2008 - 01:45 PM
Post #4


New D.I.C Head

*
Joined: 12 Sep, 2008
Posts: 23


My Contributions


This is how I use VB to create a Table.
CODE

Private Sub Command0_Click()
Dim sqlstmt As String
Dim con As DAO.Database
Set con = CurrentDb
sqlstmt = "CREATE TABLE test (First_Name TEXT(20), Last_Name TEXT(25), dob DATETIME, Constraint Employees_PK Primary Key (First_Name, Last_Name, dob));"
con.Execute (sqlstmt)
con.Close
End Sub

After the table is created just run an append query to it and it should put the rows in. (I stole the create line in here from another site but it looked right I didn’t want to create my own.) You just have to create your own sqlstmt and put the variables in it and tell it to execute. Creating a table this way it may not show up in the tabels collum untill you close and reoppen the database.

This post has been edited by dlkirk03: 9 Oct, 2008 - 01:46 PM
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 01:45PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month