Help with simple variable question

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

I want to sent a flag in one form and test it in another
form. I don't understand why my variable won't work. I
have read about "Public" and "Static", but it is not
working. Here is what I want to do. I am using Access 97

I want to set a boolean blnRecordAdded to True on Form1. I
set in the Declarations section:

Public blnRecordAdded As Boolean

Then in the Form_Open sub, I have:

Public Sub Form_Open(Cancel As Integer)
blnRecordAdded = True
End Sub

Then I open Form2 and test the variable. It is empty. How
do I get the variable over to Form2?

Thanks for any help.

Dave Aas
daveaas*AT*yahoo*DOT*com
 
To get the value of variables declared as Public in the code associated with
a form, you need to reference the form as well:

Form_Form1.blnRecordAdded

You're probably better off declaring it as Public in a module, not in the
code associated with a form.
 
The variable is part of form1, so you need to reference it as a property of
Form1, e.g.

forms("Form1").blnRecordAdded

or

Dim frm as Form

set frm = Forms("Form1")

frm.blnRecordAdded

Hope this helps
Kel
 
Thanks. How is it referenced in the form when it is
declared from a module? Is there anything special I have
to do?
 
Back
Top