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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is possible to use the value of a variable as a criteria in a query?

Status
Not open for further replies.

eXtacy

Programmer
Dec 1, 2003
21
GB
Hi

i was wondering if it is possible to use the value of a variable (that has been defined in a module as a public variable) as a criteria in a query.

I have created a security login screen where the user enters their username and password, and when access is granted the value of the user_id is saved into the public variable.

I have also created a menubar and one of the options in the menubar is [change password].

What i want is for the details of that user to display when this menu option is selected. i have tried different ways of getting around this but not getting anywhere.

this is kinda what i want to happen:

SELECT User.user_id, User.User_password
FROM [User]
WHERE User.user_id = ( variable held in module)

anyone who knows any alternative ways of how this can be done, please let me know.

Thanks a bunch.
Regards.

IKSY
 
I don't think you can reference the public variable directly in the query, but you can write a wrapper function around that variable and call the wrapper function from within the query.

WHERE User.user_id = GetPublicVariableName()

and in the Module

Public VarName as String

Public Function GetPublicVariableName() as String
GetPublicVariableName = VarName
End Function

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Hi!

Another way is to save the information to a text box on a form instead. If you have a main menu form you can create a hidden text box there and store the information. If you don't have any form that stays open all of the time then you can create a 'Criteria' form which you open hidden using the autoexec macro. You can then use that form to store any information you would normally put in public variables.

hth


Jeff Bridgham
bridgham@purdue.edu
 
hi!!

Thanks alot CajunCenturion.....That solved my problem!!

its my first time i have posted a message here and never thought i would get a reply.

U made my day!!
thanks again!!
 
You're quite welcome, and I hope that you continue to contribute to Tek-Tips, by either posting questions, or helping others by providing answers when you can.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top