Help with command button to open datasheet of contact names

Lyndon000

New member
Local time
Today, 17:44
Joined
Dec 5, 2013
Messages
6
Hi guys,

I am using Access 2013 and have basic knowledge of it.

I am trying to add a command button to my main menu to open the contact names as a datasheet, I have changed the properties on the contact names form to datasheet as well as changing the properties on the button to the below:

Private Sub Command48_Click()
DoCmd.OpenForm "Contact Names", acFormDS
End Sub

at first after I saved it, the button did nothing. Now after a bit of playing around (probably not a good idea) I have a new message that states:

"The expression On Click you entered as the event property setting produced the following error: Ambiguous name detected: Contacts_Click.

To add some additional information, in the vba sheet above the code i wrote above it says:

Option Compare Database

Private Sub Contacts_Click()
DoCmd.OpenForm "Contact Names", acFormDS
End Sub

Private Sub Contacts_Click()
DoCmd.OpenForm "Contact Names", acFormDS
End Sub

should I delete this?
 
You only need the

Private Sub Contacts_Click()
DoCmd.OpenForm "Contact Names", acFormDS
End Sub

bit once - so delete the 2nd occurrence and then compile :)
 
Delete one of the Private Sub's.
 
Thanks guys,

I have only the one private sub now and the error has gone. However the button still doesn't take me to the contact names form? Any suggestions?
 
Are you sure the button is called Contacts? If unsure, delete this code, start fresh.

Go to the design view of the Form, click the button and then follow the instructions : http://www.baldyweb.com/FirstVBA.htm

The code it again to open the Form.
 
is your button called command48, or contacts? and when you look at its event properties, does it say [event procedure] in the On Click event?
 

Users who are viewing this thread

Back
Top Bottom