Passing Variables Between Forms

funderburgh

Registered User.
Local time
Today, 05:14
Joined
Jun 25, 2008
Messages
118
I regret bringing this up again, but having read many threads on this issue, I still can't crack it.

I have a form "Logon" in which I declare a variable in the general declarations section:

Option Explicit
Public strAccess As String


Logon opens Form2 and closes.

This code in Form2 produces an error "Form Logon not found"

Private Sub Admin_Control_Click()
MsgBox [Forms]![Logon]![strAccess]
End Sub


Any help is most welcome.
 
1. You don't declare the variable in the form's General Declarations it needs to be in a STANDARD MODULE if you want to use it between two forms.

2. You don't refer to a variable in the way you are showing. It would simply be

MsgBox strAccess

and to set the variable you could in the form 1 use

strAccess = Me.SomeControl
 
Thanks - works like a charm.
 

Users who are viewing this thread

Back
Top Bottom