I have some code in a command button on a form that generates Error 2001: "You cancelled the previous operation."
I've searched this forum for fixes, and the only suggestion I found which might work for me is creating a new database and importing everything from the current one. I've tried this and it doesn't work - I get the same problem. So I don't think it's being caused by a corrupt database.
Here's my code:
Private Sub Command37_Click()
On Error GoTo Command37_Click_Error
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryCheckImportedTotals"
If (DCount("*", "tblSSTotalsExceptions", "(([tblSSTotalsExceptions].[Year] = [tblImportedTest].[Year]) AND ([tblSSTotalsExceptions].[Payno] = [tblImportedTest].[Pay No]) AND ([tblSSTotalsExceptions].[Week] = [tblImportedTest].[Week No]))") > 0) Then
If (MsgBox("The totals listed on the Excel spreadsheets don't match the sum total of the individual records. Would you like to see tblSSTotalsExceptions?", vbYesNo + vbQuestion) = vbYes) Then
DoCmd.OpenTable "tblSSTotalsExceptions"
End If
End If
DoCmd.SetWarnings True
Command37_Click_Exit:
Exit Sub
Command37_Click_Error:
MsgBox Err.Description, vbCritical, "Error #: " & Err.Number
Resume Command37_Click_Exit
End Sub
When I Debug, the problem registers on the "If (DCount ..." line.
Does anyone know what's causing this problem, and how I might fix it?
thanks!
I've searched this forum for fixes, and the only suggestion I found which might work for me is creating a new database and importing everything from the current one. I've tried this and it doesn't work - I get the same problem. So I don't think it's being caused by a corrupt database.
Here's my code:
Private Sub Command37_Click()
On Error GoTo Command37_Click_Error
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryCheckImportedTotals"
If (DCount("*", "tblSSTotalsExceptions", "(([tblSSTotalsExceptions].[Year] = [tblImportedTest].[Year]) AND ([tblSSTotalsExceptions].[Payno] = [tblImportedTest].[Pay No]) AND ([tblSSTotalsExceptions].[Week] = [tblImportedTest].[Week No]))") > 0) Then
If (MsgBox("The totals listed on the Excel spreadsheets don't match the sum total of the individual records. Would you like to see tblSSTotalsExceptions?", vbYesNo + vbQuestion) = vbYes) Then
DoCmd.OpenTable "tblSSTotalsExceptions"
End If
End If
DoCmd.SetWarnings True
Command37_Click_Exit:
Exit Sub
Command37_Click_Error:
MsgBox Err.Description, vbCritical, "Error #: " & Err.Number
Resume Command37_Click_Exit
End Sub
When I Debug, the problem registers on the "If (DCount ..." line.
Does anyone know what's causing this problem, and how I might fix it?
thanks!