Run-time error '2501': The OpenForm action was cancelled
Posted on 2007-10-17
Users get the run time error in 2003 when trying to open a form called frmDayHistory. Funny thing is it doesnt happen in 2007, and was thinking it may be reference llibrary?? just guessing...
Anyway here is the code which fails on the very last line "Docmd.Openform"...
Private Sub Command6_Click()
Dim BCSDb As DAO.Database
Dim RSPN As DAO.Recordset
Dim sqlinfo As String
Dim strReportDate As String
Dim ReportDate As String
If Len(Me.TxtDate & vbNullString) = 0 Then
MsgBox "Please ensure that a report date is entered into the form", _
vbInformation, "Required Data..."
'strReportDate = Day(CDate(Me.TxtDate)) & "/" & _
'Month(CDate(Me.TxtDate)) & "/" & _
strReportDate = Month(CDate(Me.TxtDate)) & "/" & _
Day(CDate(Me.TxtDate)) & "/" & _
ReportDate = "(#" & strReportDate & "#)"
'MsgBox ReportDate, vbInformation
DoCmd.RunSQL "UPDATE tblDate SET ReportDate = " & ReportDate & ""
sqlinfo = "SELECT * FROM tblScrapRecords WHERE Date = " & ReportDate & ""
'MsgBox sqlinfo, vbInformation
Set BCSDb = CurrentDb
Set RSPN = BCSDb.OpenRecordset(sqlinfo, dbOpenSnapshot)
If RSPN.BOF = True And RSPN.EOF = True Then
MsgBox "There are no records for " & Me.TxtDate & ". Please ensure you have entered the correct date "
DoCmd.OpenForm "frmDayHistory", acPreview