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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If statement in macro (if certain form is open, then...) 1

Status
Not open for further replies.

mark01

Technical User
Jan 17, 2001
600
US
Does anyone know how to put this in a macro...
IF form ABC is open (the current form being displayed on the screen), THEN open form XYZ.
I just don't know how to put it in the condition of the macro. Thanks.
smiletiniest.gif
 
You really can't do anything that specific with a macro. Instead try using VBA to do what you want
 
OK, so how would I do that in Visual Basic then???
smiletiniest.gif
 
I.e
This will give you some ideas

go to the ABC form goto properties> then go under Event> OnOpen


Private Sub Form_Open(Cancel As Integer)

docmd.openform "XYZ"

end sub
 
Well, I originally wanted to put in a macro that would be called autokeys, so I can use Ctrl-P to bring up my own print form, but I have 3 forms, and 3 different print menu's for each form. So I want to push Ctrl-P, and it will bring up the correct form for the current form that is open. So if I am in ABC form, I push Ctrl-P, and it will bring up ABC Print menu. Then if I was in XYZ form, I can push Ctrl-P, and it will bring up the XYZ print menu.(This is what I was hoping for)
 
Try using the IsLoaded function.

This is not a built-in Access function, but it is in the Northwind sample database that is included with Access. Import the module from Northwind into your db and then use it as you would any other function.

Something like:

Code:
If IsLoaded(Form1) Then
    ......  'Do whatever
Else
    If Isloaded(Form2) Then
        ...  'Do Something else
    End If
end If

HTH

Lightning
 
If you want to open form B while form A is open, why not just put in a command button to open form B on click??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top