By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,446 Members | 2,998 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,446 IT Pros & Developers. It's quick & easy.

Mysterious errors with Event Procedure on one form

P: n/a
Every thing worked fine until all of a sudden, I get the following error
whenever I try to do anything on one of my forms that calls an Event
Procedure. I get the error as soon as the form opens because I have an
OnLoad event. If I take that out the form will open but I will get the same
error if I attempt anything else that will call and Event Procedure. I am
not having any issues with any other forms.

Error is:

The expression On Load you entered as the event property setting produced
the following error: Event procedure declaration does not match description
of event having the same name.

Prior to this problem, I was attempting to pass a variable from an unbound
control on the problem form to another form. I have since returned both
forms back to their original state (at least I think I have). Ive included
the code for the form that I'm having this problem with, if that might help.
Any suggestions?

Some items that might look suspicious to you:
EnableControls - this calls a module that disables the main form controls
until two combo boxes in the header have been used to select criteria. I
borrowed the code from MS Solutions database. This worked prior to this
problem and has not been altered.

Code follows:

Private Sub ClientID_Enter()
MsgBox "You cannot edit this field."
Me!ProjectLocation.SetFocus
End Sub

Private Sub Form_AfterUpdate()

' Requery SelectProduct combo box.
Me!SelectProject.Requery

End Sub

Private Sub Form_Load()
Me!SelectClient.SetFocus
EnableControls Me, acDetail, False
End Sub

Private Sub Project_Enter()
MsgBox "You cannot edit this field."
Me!ProjectLocation.SetFocus
End Sub

Private Sub RefreshClient_Click()

' Requery SelectClient combo box.
Me!SelectClient.Requery

End Sub

Private Sub RefreshProjectID_Click()

' Requery SelectProject combo box.
Me!SelectProject.Requery

End Sub

Private Sub SelectClient_AfterUpdate()

' Enable and requery SelectProduct combo box.
' Disable controls in detail section.

Me!SelectProject.Enabled = True
Me!SelectProject.Requery
EnableControls Me, acDetail, False
End Sub

Private Sub SelectClient_DblClick(Cancel As Integer)
On Error GoTo Err_SelectClient_DblClick

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmClients"
DoCmd.OpenForm stDocName, acNormal, , , acFormAdd, acWindowNormal

Exit_SelectClient_DblClick:
Exit Sub

Err_SelectClient_DblClick:
MsgBox Err.Description
Resume Exit_SelectClient_DblClick

End Sub

Private Sub SelectProject_AfterUpdate()

' Find record for product selected in SelectProduct combo box.
' Enable controls in detail section and disable ProductID text box.
' Go to SupplierID combo box.

DoCmd.ApplyFilter , "ProjectID = Forms!frmWorksheet!SelectProject"
EnableControls Me, acDetail, True
Me!ProjectID.Enabled = False
Me!ProjectLocation.SetFocus
End Sub

Private Sub SelectProject_BeforeUpdate(Cancel As Integer)
If IsNull([SelectProject]) Then
MsgBox "You must select a project."
Cancel = True
End If

End Sub

Private Sub SelectProject_DblClick(Cancel As Integer, NewData As String)
On Error GoTo Err_SelectProject_DblClick

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmNewProject"
DoCmd.OpenForm stDocName, acNormal, , , acFormAdd, acWindowNormal
'DoCmd.OpenForm stDocName, acNormal, , , acFormAdd, acDialog,
"[ClientID] = [ClientID}"
'DoCmd.OpenForm stDocName, , , , , , Me!SelectClient.Column(3)
'DoCmd.OpenForm stDocName, acNormal, , , acFormAdd, acDialog, NewData

Exit_SelectProject_DblClick:
Exit Sub

Err_SelectProject_DblClick:
MsgBox Err.Description
Resume Exit_SelectProject_DblClick

End Sub
May 14 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Sorry, I spoke too soon. Just figured out what the problem was (although not
why). A friend suggested I CAREFULLY study the code to see if the syntax was
wrong somewhere. It wasn't syntax exactly but...

In the following sub, I was trying different methods to accomplish the info
transfering thing and then commented out the code when I tried something
new. Unfortunately a piece from the last comment line (the one that ends in
NewData) was left behind; "NewData As String" in the declarations. I deleted
this bit and the form works fine now. I don't understand why, when I used
the last line as code, I didn't have any trouble, but with it commented out,
the declaration line gave me trouble.

Private Sub SelectProject_DblClick(Cancel As Integer, NewData As String)
On Error GoTo Err_SelectProject_DblClick

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmNewProject"
DoCmd.OpenForm stDocName, acNormal, , , acFormAdd, acWindowNormal
'DoCmd.OpenForm stDocName, acNormal, , , acFormAdd, acDialog,
"[ClientID] = [ClientID}"
'DoCmd.OpenForm stDocName, , , , , , Me!SelectClient.Column(3)
'DoCmd.OpenForm stDocName, acNormal, , , acFormAdd, acDialog, NewData

Exit_SelectProject_DblClick:
Exit Sub

Err_SelectProject_DblClick:
MsgBox Err.Description
Resume Exit_SelectProject_DblClick

End Sub

May 14 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.