public declared variable used in a query?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I capture the userID in my login startup form. I then set it = to a publicly
declared variable currentuserID. I tried to use the currentuserID in a query
but I get an error.

In my query I have under userID
= currentuserID
Access automatically puts quotations around it as follows
= "currentuserID"
and I get a type mismatch error.

What am I doing wrong?
 
tsison7 wrote in message
I capture the userID in my login startup form. I then set it = to a
publicly declared variable currentuserID. I tried to use the
currentuserID in a query but I get an error.

In my query I have under userID
= currentuserID
Access automatically puts quotations around it as follows
= "currentuserID"
and I get a type mismatch error.

What am I doing wrong?

I gave the below answer to similar question earlier today

"Not directly, but through a public function residing also in a
standard
module.

public function GetMyVariable() as <your data type>
GetMyVariable = g_MyPublicVariable
end function

Then refer to that function both in the query and report. Note again,
that the function must reside in a standard module, not a forms/reports
module."
 
Create a function that returns that public variable. Call the function in
your query.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top