Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending data to a Query using Access Variables.?

Status
Not open for further replies.

MrSquishy

Programmer
Dec 7, 2000
1
AU
Hello All,

I need a little help in sending the data in a access basic variable to a query, so far I have a form with NewLocation,NewStatus as variables, I update these variables and run the update query. in the query I have
[Forms]![DataEntry]![NewLocation], etc, in the Update To area. I have also tried creating Functions to replace the variables, but I'm not 100% sure I did it correctly, could someone provide an example of what I would put in the query's Update To box.? and maybe what a Function looks like if possible..?


TIA
 
Queries cannot just read variables. There is only one way to do this, and it's actually very simple. First, make your variable public, and second create a function to read the variable. Then call the function in the criteria for the query, for example.

In a module:
===============
Public NewLocation As String
Public NewStatus As String

Public Function GetNewLocation() As String
GetNewLocation = NewLocation
End Function

Public Function GetNewStatus() As String
GetNewStatus = NewStatus
End Function
===============

Now in the criteria in the query, simply put the following:

=GetNewLocation() OR
=GetNewStatus()

The setting of your variables doesn't need to change, as they are just public now instead of private.

Hope this helps.
Jim Lunde
compugeeks@hotmail.com
Custom Application Development
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top