Microsoft DoubleClick not working

Steven Deetz

Registered User.
Local time
Today, 16:11
Joined
Jul 19, 2001
Messages
49
In several database wizards, Microsoft includes a neat feature when a user double clicks on a combo box a form will open up to add a new field of data to the list the combo box is tied to.

As a donation, I am re-writing a Bowl-for-Kids Sake program for the local Big Brothers Big Sisters chapter. Bowlers go out and collect Sponsors. Each bowler can have many sponsors and each sponsor can have many bowlers.

When I try the rebuild the Microsoft example code for the combo box's Dbl Click property, the form to add a new sponsor opens up but will not go to the new record. Anyone have any ideas why the "GoToNew" in the OpenArgs does not want to work? Thanks!

Private Sub cboSponsorLookup_DblClick(Cancel As Integer)
On Error GoTo Err_cboSponsorLookup_DblClick
Dim intSponsorID As Long

If IsNull(Me![cboSponsorLookup]) Then
Me![cboSponsorLookup].Text = ""
Else
intSponsorID = Me![cboSponsorLookup]
Me![cboSponsorLookup] = Null
End If

DoCmd.OpenForm "Sponsors", , , , , acDialog, "GoToNew"
Me![cboSponsorLookup].Requery
If intSponsorID <> 0 Then Me![cboSponsorLookup] = intSponsorID

Exit_cboSponsorLookup_DblClick:
Exit Sub

Err_cboSponsorLookup_DblClick:
MsgBox Err.Description
Resume Exit_cboSponsorLookup_DblClick

End Sub
 
Have you tried setting the form's dataentry property to yes?
 
Have you tried putting in the on_open event of the "Sponsors" form:

DoCmd.GoToRecord , , acNewRec

HTH
 
Thanks charityg and Irie for the help. I started looking on the Microsoft example form to see if your ideas would point toward a solution. I found the code I was looking for in the Form_Load event.

Private Sub Form_Load()
If Me.OpenArgs = "GoToNew" And Not IsNull(Me![Sponsor ID]) Then
DoCmd.DoMenuItem acFromBar,3,0,,acMenuVer70
End If
End Sub

If I understand this correctly the openargs is like a tag that accompanies the code in my first post. The code above looks for it and uses it during the loading of the Sponsor Form. The code above only uses it if there are already records, since if there were none there would be no need to make a new record. The only thing I am having difficulty understanding is the
DoCmd.DoMenuItem acFormBar,3,0,,acMenuVer70
I believe this is telling Access to create a new record; however the numbers 3 and 0 and the acMenuVer70 are cryptic.

Thanks again for your help!
 

Users who are viewing this thread

Back
Top Bottom