Close a Form

G

Guest

I have the following event for my form - frmContact that updates the
contactID of a different form if its open.
Private Sub Form_Close()
Forms!frmMain!frmSub.Form!ContactID = Me.ContactID
Forms!frmMain!frmSub.Form!ContactID.Requery
End Sub

What do I need to add to it so that if frmContact is opened and the frmMain
closed. Bcoz it gives me a run-time error 2405 that frmMain reffered to in a
macro expression or visual basic code
 
G

Guest

You could try :-

Private Sub Form_Close()
If CurrentProject.AllForms("frmMain").IsLoaded = True Then
Forms!frmMain!frmSub.Form!ContactID = Me.ContactID
Forms!frmMain!frmSub.Form!ContactID.Requery
Else
MsgBox "Cannot update Main form"
End If
End Sub

Good Luck
 
G

Guest

Thank you that worked!

Peter Hibbs said:
You could try :-

Private Sub Form_Close()
If CurrentProject.AllForms("frmMain").IsLoaded = True Then
Forms!frmMain!frmSub.Form!ContactID = Me.ContactID
Forms!frmMain!frmSub.Form!ContactID.Requery
Else
MsgBox "Cannot update Main form"
End If
End Sub

Good Luck
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top