MS Access is driving me insane. For seemly no reason I get the following error message when I try to load the main form in my Access DB: -
"The expression On Open you entered as the event property setting produced the following error: Procedure declaration does not match description of event or procedure having the same name".
Having browsed the Tek-Tips forum for a few hours I've found other people have had the same error where the sub routine name is used more than once or if the sub routine was not created by using the ... button on the On Open event list (from the form properties events list). But this isn't the case here.
1) The routine was created using the .. button.
2) The name of the routine is used only ONCE.
3) I've tried deleting the module attached to the form and re-entering the data
4) I've tried delting the specific On Open sub routine and any reference to it, re-creating it using the ... button and pasting back in the lines of code between the sub declaration and the end sub marker.
All of the above have done nothing to fix the problem.
The offending bit of code is listed below...
Private Sub Form_Open(Cancel As Integer)
Dim AdUsers As New ADODB.Recordset
fail_count = 0
DoCmd.SetWarnings False
DoCmd.OpenQuery "qry_del"
DoCmd.OpenQuery "qry_copy"
new_active = False
DoCmd.SetWarnings True
AdUsers.Open "SELECT * FROM tbl_Admins", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
AdUsers.MoveFirst
Admin = False
Admin_Mode = False
While Not AdUsers.EOF
With AdUsers
If AdUsers!UserID = fOSUserName Then Admin = True
AdUsers.MoveNext
End With
Wend
HToolBars
data_entry = False
If Admin = False Then
box_Admin.Visible = False
lbl_Admin.Visible = False
btn_Email.Visible = False
btn_Tools.Visible = False
frm_boolean.Visible = False
lbl_Update.Caption = "SUBMIT CALL"
Else
box_Admin.Visible = True
lbl_Admin.Visible = True
btn_Email.Visible = True
btn_Tools.Visible = True
frm_boolean.Visible = True
DoCmd.OpenForm "frm_tools", acNormal
lbl_Update.Caption = "SAVE / UPDATE"
End If
ErrorDate_Label_DblClick
frm_boolean = 1
End Sub
The reason why I say this appears to happen for no reason is because this sub routine always used to work (this is about the 50th incarnation of this horrible DB). The only change to the code that messed up the execution was the call to the routine "ErrorDate_Label_DblClick" on the 3rd to last line, and said line of code has been commented out, removed, re-typed, cut/pasted and swore at all to no avail in my attempts to get rid of this error message. I have a backup of this DB where this line of code doesn't exist and neither does the routine it calls. I've checked the routine several times and can't see anything wrong with it (it works if ran in isolation).
Any help is much appreciated.
"The expression On Open you entered as the event property setting produced the following error: Procedure declaration does not match description of event or procedure having the same name".
Having browsed the Tek-Tips forum for a few hours I've found other people have had the same error where the sub routine name is used more than once or if the sub routine was not created by using the ... button on the On Open event list (from the form properties events list). But this isn't the case here.
1) The routine was created using the .. button.
2) The name of the routine is used only ONCE.
3) I've tried deleting the module attached to the form and re-entering the data
4) I've tried delting the specific On Open sub routine and any reference to it, re-creating it using the ... button and pasting back in the lines of code between the sub declaration and the end sub marker.
All of the above have done nothing to fix the problem.
The offending bit of code is listed below...
Private Sub Form_Open(Cancel As Integer)
Dim AdUsers As New ADODB.Recordset
fail_count = 0
DoCmd.SetWarnings False
DoCmd.OpenQuery "qry_del"
DoCmd.OpenQuery "qry_copy"
new_active = False
DoCmd.SetWarnings True
AdUsers.Open "SELECT * FROM tbl_Admins", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
AdUsers.MoveFirst
Admin = False
Admin_Mode = False
While Not AdUsers.EOF
With AdUsers
If AdUsers!UserID = fOSUserName Then Admin = True
AdUsers.MoveNext
End With
Wend
HToolBars
data_entry = False
If Admin = False Then
box_Admin.Visible = False
lbl_Admin.Visible = False
btn_Email.Visible = False
btn_Tools.Visible = False
frm_boolean.Visible = False
lbl_Update.Caption = "SUBMIT CALL"
Else
box_Admin.Visible = True
lbl_Admin.Visible = True
btn_Email.Visible = True
btn_Tools.Visible = True
frm_boolean.Visible = True
DoCmd.OpenForm "frm_tools", acNormal
lbl_Update.Caption = "SAVE / UPDATE"
End If
ErrorDate_Label_DblClick
frm_boolean = 1
End Sub
The reason why I say this appears to happen for no reason is because this sub routine always used to work (this is about the 50th incarnation of this horrible DB). The only change to the code that messed up the execution was the call to the routine "ErrorDate_Label_DblClick" on the 3rd to last line, and said line of code has been commented out, removed, re-typed, cut/pasted and swore at all to no avail in my attempts to get rid of this error message. I have a backup of this DB where this line of code doesn't exist and neither does the routine it calls. I've checked the routine several times and can't see anything wrong with it (it works if ran in isolation).
Any help is much appreciated.