Command button code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using the Access ContactMgmt db template. When entering a contact you can click the calls button which opens the calls form, however it leaves the contacts form open. I want to add a line of code to close the contats form upon opening the calls form. This is the existing open code:

Private Sub Call_Details_Click()
On Error GoTo Err_Calls_Details_Click
If IsNull(Me![ContactID]) Then
MsgBox "Enter contact information before making a call."
Else
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm "Calls"
DoCmd.CloseForm "Contacts" ( I added this to the code and keep getting errors)

End If

Exit_Calls_Details_Click:
Exit Sub

Err_Calls_Details_Click:
MsgBox Err.Description
Resume Exit_Calls_Details_Click
End Sub

What can I add to this to open the calls form and close the contacts form. Please help.
 
Make sure you have intellisense enabled. CloseForm is not
a method of the DoCmd Object.


DoCmd.Close acForm,"Contacts"


Chris

-----Original Message-----
I am using the Access ContactMgmt db template. When
entering a contact you can click the calls button which
opens the calls form, however it leaves the contacts form
open. I want to add a line of code to close the contats
form upon opening the calls form. This is the existing
open code:
Private Sub Call_Details_Click()
On Error GoTo Err_Calls_Details_Click
If IsNull(Me![ContactID]) Then
MsgBox "Enter contact information before making a call."
Else
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm "Calls"
DoCmd.CloseForm "Contacts" ( I added this to the code and keep getting errors)

End If

Exit_Calls_Details_Click:
Exit Sub

Err_Calls_Details_Click:
MsgBox Err.Description
Resume Exit_Calls_Details_Click
End Sub

What can I add to this to open the calls form and close
the contacts form. Please help.
 
I have tried adding the DoCmd.Close acForm,"Contracts" and nothing happens. How exactly should this DoCmd be added to the code below

----- Chris wrote: ----

Make sure you have intellisense enabled. CloseForm is not
a method of the DoCmd Object


DoCmd.Close acForm,"Contacts


Chri

-----Original Message----
I am using the Access ContactMgmt db template. When
entering a contact you can click the calls button which
opens the calls form, however it leaves the contacts form
open. I want to add a line of code to close the contats
form upon opening the calls form. This is the existing
open code
Private Sub Call_Details_Click(
On Error GoTo Err_Calls_Details_Clic
If IsNull(Me![ContactID]) The
MsgBox "Enter contact information before making a call.
Els
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer7
DoCmd.OpenForm "Calls
DoCmd.CloseForm "Contacts" ( I added this to the code and keep getting errors
End I
Exit_Calls_Details_Click Exit Su
Err_Calls_Details_Click
MsgBox Err.Descriptio
Resume Exit_Calls_Details_Clic
End Su
What can I add to this to open the calls form and close
the contacts form. Please help
 
Back
Top