DoCmd.OpenForm won't work, Procedure declaration does not match description

starrcruise

Registered User.
Local time
Today, 12:52
Joined
Mar 4, 2011
Messages
18
I am beside myself with this. Originally I coded the Docmd.Open code with a string to open to a specific record. Worked beautifully. Today (did not shut anything down) the form will not even run the simple DoCmd.OpenForm "formname" code without getting the below message. I have plugged in different form names to be sure it wasn't an OnLoad thing. But in desperation I plugged in a macros in a command button on this same form asking it to open the same forms and it worked.

Error: Procedure declaration does not match description of event or procedure having the same name.

original simplified code:
Private Sub SourceID_Click()
DoCmd.Form "frmEditSource"
End Sub

Please help. I am under the wire here. Thank you.
 
thank you for the quick reply. I use this forum constantly and it has saved my .... a lot. Anyways, being the impatient crazy woman I am, while waiting for your reply, I clicked on other coded buttons and controls, ie, Save, Close, on the problem form and ALL of them came back with the same error message. So I went to a backup of my database to the same form with the same coding and it worked beautifully. So I am assuming that my form or some of the controls somehow became corrupted? But, I am now confused over the coding. I am assuming there are more ways than one because this is the code I am using (both SerialNo and cboProjectSerial are text)

Private Sub cboJobAidNumber_DblClick(Cancel As Integer)
Dim stLinkCriteria As String

On Error GoTo Error_Handler

'Allows user to click on number and opens record in edit Job Aid form

stLinkCriteria = "[SerialNo]='" & Me![cboJobAidNumber] & "'"

DoCmd.OpenForm FormName:="Edit Job Aid/ Training Materials", _
wherecondition:=stLinkCriteria



Exit_Procedure:
On Error Resume Next
Exit Sub

Error_Handler:
MsgBox "An Error has occurred in this application." _
& "Please contact your technical support and " _
& "tell them this information:" _
& vbCrLf & vbCrLf & "error Number " & Err.Number & ", " _
& Err.Description, _
Buttons:=vbCritical
End Sub

Please tell me the most efficient code for the above? In the meantime, I am going to try your code in the "corrupted" form just to see what happens.

thank you so much. You guys rock! I'm always in awe.
 
But, I am now confused over the coding. I am assuming there are more ways than one because this is the code I am using (both SerialNo and cboProjectSerial are text)

Private Sub cboJobAidNumber_DblClick(Cancel As Integer)
Dim stLinkCriteria As String

On Error GoTo Error_Handler

'Allows user to click on number and opens record in edit Job Aid form

stLinkCriteria = "[SerialNo]='" & Me![cboJobAidNumber] & "'"

DoCmd.OpenForm FormName:="Edit Job Aid/ Training Materials", _
wherecondition:=stLinkCriteria



Exit_Procedure:
On Error Resume Next
Exit Sub

Error_Handler:
MsgBox "An Error has occurred in this application." _
& "Please contact your technical support and " _
& "tell them this information:" _
& vbCrLf & vbCrLf & "error Number " & Err.Number & ", " _
& Err.Description, _
Buttons:=vbCritical
End Sub

Please tell me the most efficient code for the above?
The code is fine.

In the meantime, I am going to try your code in the "corrupted" form just to see what happens.
I was just pointing out that it's not just DoCmd.Form, it's DoCmd.OpenForm.
 
Awesome. Again, I can't thank you enough for the quick response.
 
[Edit Job Aid/ Training Materials] is not a nice name for an object.

Best practice avoids spaces and special characters.
 
[Edit Job Aid/ Training Materials] is not a nice name for an object.

Best practice avoids spaces and special characters.

I concur with Galaxiom here. Don't use spaces or special characters in names of anything. It will simplify things immensely and keep from some potential issues from popping up.
 
thank you, guys. I absolutely agree, but I inherited this "blessed" DB and couldn't bear to rewrite a bunch of code. I have learned a ton from this Forum so Thanks again for the advice. The spaces are bad enough, but how about that "/"?:confused: I have another problem, but it is not vba. start a new thread?
 

Users who are viewing this thread

Back
Top Bottom