Selecting data based on a variable

Withnail

New member
Local time
Today, 14:30
Joined
Apr 5, 2001
Messages
7
Hello all.

I've got a feeling this could be extremely easy to answer, but here goes.

How do I open up a form displaying data where the UniqueID of the record matches a variable?

I have a global variable MyUserNameIdentifier (stored as an Integer) which is the UniqueID of the user once he/she has logged on correctly to the database.

If the user wants to change their logon details, I want a form that brings up their relevant details based upon the value of the variable. However it seems I cannot enter variables within query criteria, and I've had no success with OpenArgs. I suspect that I would need to write a Function but I'm not sure how to go about this.

Many thanks

Withnail
 
If you want to use VBA code, try this:

DoCmd.OpenForm "MyForm", , ,"MyUserNameIdentifier = '" & UniqueID & "'"

You could also store the value of MyUserNameIdentifier in a hidden textbox on some other form, and then specify your query criteria as:

[Forms]![SomeForm]![SomeTextbox]

If you want a function to use as a query criteria, this should work:

Function UserID as Integer()
UserID = MyUserNameIdentifier
End Function

[This message has been edited by AlanS (edited 04-06-2001).]
 

Users who are viewing this thread

Back
Top Bottom