Variable in another module

N

nexus

I have declared a variable in this module Main Menu, say

Public Sub Exit_Click()
Dim strTest as String
End Sub

(imagine there's a value to strTest)

Now i wan to store this variable in another module,
Enquiry Form. The enquiry page has a textbox called
txtEnqNo and i wan the variable strTest to be display in
the txtEnqNo during form view. How do i do that?
I tried putting these codes under the Enquiry form

strTest = Forms!frmEnqMain!txtEnqNo

but it doesnt work. Is there any way i can solve this?
 
A

Alex Dybenko

to set variable value strTest to value of texbox - syntax is correct
strTest = Forms!frmEnqMain!txtEnqNo
just make just you fist test textbox to null value, else you get error

to set textbox to variable value - you can make a public function in common
module, which returns a value of variable, and then in textbox control
source write:
=GetMyVar()

public function GetMyVar()
GetMyVar=strtest
end function

in this case strTest should be bublic also, or at least declared at this
module level
 

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