I'm currently trying to fix a bug in a form. On a subform within a form, there is a command button to open up another form. Based on two conditions, it will open up the new form showing the details of that record. (Project ID and Project Date)
It works fine mostly, but sometimes it throws up a run time error, number 2001 "You have cancelled the previous operation". I have 2 copies of the database, one which works fine and another which is currently broken. The problem is that the working version is likely to break on a regular basis.
I have compared the VBA from both versions behind the command button, but still the error exists on the broken version even though the code is exactly the same. Any idea why this is happening?
Code:
Private Sub Command35_Click()
On Error GoTo Err_Command35_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "2e - Project Status Detail Reporting Form"
stLinkCriteria = "[Project ID]=" & Me![Project ID] & "AND me![Project Status Date]=" & "#" & [Project Status Date] & "#"
Refresh
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command35_Click:
Exit Sub
Err_Command35_Click:
If Err.Number = 2001 Then
MsgBox "Error 2001"
End If
Resume Exit_Command35_Click
End Sub
Any help would be greatly appreciated
It works fine mostly, but sometimes it throws up a run time error, number 2001 "You have cancelled the previous operation". I have 2 copies of the database, one which works fine and another which is currently broken. The problem is that the working version is likely to break on a regular basis.
I have compared the VBA from both versions behind the command button, but still the error exists on the broken version even though the code is exactly the same. Any idea why this is happening?
Code:
Private Sub Command35_Click()
On Error GoTo Err_Command35_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "2e - Project Status Detail Reporting Form"
stLinkCriteria = "[Project ID]=" & Me![Project ID] & "AND me![Project Status Date]=" & "#" & [Project Status Date] & "#"
Refresh
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command35_Click:
Exit Sub
Err_Command35_Click:
If Err.Number = 2001 Then
MsgBox "Error 2001"
End If
Resume Exit_Command35_Click
End Sub
Any help would be greatly appreciated