results of a query in global variable ...

M

Me

I have a need to store results of a query in global variable for
later use.

I created a module with function as

Function GetMyVariable() As String
GetMyVariable = strMyvariable
End Function

I also tried with the following code -

Function GetMyVariable(strMyvariable) As String
GetMyVariable = strMyvariable
End Function

I created a form that calls the query

In the form, I have

Private Sub Form_Open(Cancel As Integer)
strMyvariable = Forms!CurrentUser!Myvariable
GetMyVariable (strMyvariable)
MsgBox ("form my variable") & strMyvariable & " var " &
GetMyVariable(strMyvariable)

shows me the values correctly.

However, I created another form wherein I try to retrieve the value of
strMyvariable, it doesn't show anything.

I even put the following display to see the values
MsgBox ("form my vraible") & strMyvariable & " var " &
GetMyVariable(strMyvariable)

What am I doing wrong?

Thanks for your help!
-Me
 

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

Top