Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ignoring Access variables 1

Status
Not open for further replies.

RPGguy

Programmer
Jul 27, 2001
73
US
I have a form that I want to call from 3 different forms. Only one of the 3 will add records and passes a Public variable needed when adding records. I want the other 2 forms to use this form but not have a window pop up looking for the missing variable. Any ideas?

Thanks,
Scott
 
Perhaps the simplest, but potentially bug-ridden way is to create some public variables (in a module) which are set as boolean & become true when each of the forms become open. When the subsequent form is called, you can set it to only ask for the parameter value if the correct form called it:

Module 1:
Public Form1Open as Boolean, Form2Open as Boolean
Public Form3Open as Boolean

Form1 Module:
Private Sub Form_Open()
Form1Open = True

Private Sub Form_Close()
Form1Open = False

Form2 Module:
Private Sub Form_Open()
Form2Open = True

Private Sub Form_Close()
Form2Open = False

Form3 Module:
Private Sub Form_Open()
Form3Open = True

Private Sub Form_Close()
Form3Open = False


Called Form Module:

Private Sub Form_Open()
If Form1Open = True Then
Add code here
ElseIf Form2Open = True Then
Add code here
ElseIf Form3Open = True Then
Add code here
End If


In theory this will test to see which form is open & subsequently which form is calling the next form. However it will get very confused if you have more than one of the forms open, so you could implement a similar method to ensure no other forms are open.

The alternate is to use DAO to test for the forms being open, & which is calling it. This is perhaps more thourough & less bug-ridden, but I think it is a lot more complicated, so I generall avoid using it.
James Goodman
j.goodman00@btinternet.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top