Close a Form

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
Back
Top