Problems with VBA & Queries...!!?

masterkale

AuzSolutions
Local time
Today, 20:12
Joined
Sep 19, 2006
Messages
22
To start with if your going to explain anything... lets just say im a noob.. :)


I have a login form which passes the info to a sub routine in one of my modules...

Option Compare Database


Global MyStrUserId As String
Global MyStrUserActive As String
Global MyStrUserSecurityLevel As String

This info above is in the general declarations...i can access the stored (in memory) data that gets saved as global strings.

Now i can take this info and use it on other forms message boxs private subs etc etc...

But for the life of me HOW do i use this info in the where query statement...?!?!

Eg.

I have a query which displays records from a usermessages table. This query displays all the records based on the userid where userid = forms!frmmain.txtuserlogedin.value

what i want is where userid = MyStrUserId

but this doesn't work as the SQL engine does not see the global defined variable...???

Cheers
Tristan F
 
Hi
Create a global function that returns your variable. You can then have:
where userid = MyStrUserId()
where MyStrUserId() is the fucntion you have created to return your variable.
hth
Stopher
 

Users who are viewing this thread

Back
Top Bottom