Opening and Closing Forms

Graybeard

Registered User.
Local time
Yesterday, 22:15
Joined
Aug 7, 2004
Messages
64
Im not sure if this a forms question or a macro question but I will ask it here. I currently run macros to open a form and close the previous form that has been open. Thr ptoblem is the previous form is not always open so that when the macro runs and the previous form is not open The user gets an error message. I'm guessing I have to use code instead of a macro-perhaps an IF statement . IF form open close it else go to end but dont know exact syntax. Can someone help me?
 
why dont you use the close event of the form. forexample

onclose of the customer form open invoce form

docmd.openform "Invoice"

in this case you woul not have to use the macro.

by the ways whats the point of using this method ... i mean that closing one form and opening other form... instead you can use the Switchboard. that would be much helpful

hope this would help you

take care
 
Search the forum for the IsLoaded function. It is a custom function from the Northwind sample that will allow you to test if a form, table, etc. is open.

I prefer to close my form in the event that I am using to open another form.
Code:
Private Sub btnOpenAnotherForm_Click()
        
    DoCmd.OpenForm "frmAnotherform", acNormal
    DoCmd.Close acForm, Me.Name 'close current form
    
End Sub
 

Users who are viewing this thread

Back
Top Bottom