E
Edgar Thoemmes
Hi
I am trying to use the code below to create a query on the fly, it is coming
up with the error 'You Cancelled the previous operation' on the following
line.
DoCmd.OpenQuery ("qrySearch")
Does anyone know what this error message means - Access help has no info.
Thanks in advance
Public Sub CmdSearch_Click()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("qrySearch")
If Me.chkAnnulled.Value = -1 Then
strAnnulled = "Yes"
Else
strAnnulled = "No"
End If
strSQL = "SELECT tbl_Contracts.SupplierID,
tbl_Contracts.ContractDescription, tbl_Contracts.StartDate, " & _
"tbl_Contracts.EndDate, tbl_Contracts.NoticePeriod,
tbl_Contracts.ReviewDate, tbl_Contracts.ContractNotes,
tbl_Contracts.AnnulledContract" & _
" FROM tbl_Contracts" & _
" WHERE tbl_Contracts.EndDate<Date()-" & StrDate & " AND
tbl_Contracts.AnnulledContract='" & strAnnulled & "';"
'Debug.Print strSQL
qdf.SQL = strSQL
DoCmd.OpenQuery ("qrySearch")
Set qdf = Nothing
Set db = Nothing
End Sub
I am trying to use the code below to create a query on the fly, it is coming
up with the error 'You Cancelled the previous operation' on the following
line.
DoCmd.OpenQuery ("qrySearch")
Does anyone know what this error message means - Access help has no info.
Thanks in advance
Public Sub CmdSearch_Click()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("qrySearch")
If Me.chkAnnulled.Value = -1 Then
strAnnulled = "Yes"
Else
strAnnulled = "No"
End If
strSQL = "SELECT tbl_Contracts.SupplierID,
tbl_Contracts.ContractDescription, tbl_Contracts.StartDate, " & _
"tbl_Contracts.EndDate, tbl_Contracts.NoticePeriod,
tbl_Contracts.ReviewDate, tbl_Contracts.ContractNotes,
tbl_Contracts.AnnulledContract" & _
" FROM tbl_Contracts" & _
" WHERE tbl_Contracts.EndDate<Date()-" & StrDate & " AND
tbl_Contracts.AnnulledContract='" & strAnnulled & "';"
'Debug.Print strSQL
qdf.SQL = strSQL
DoCmd.OpenQuery ("qrySearch")
Set qdf = Nothing
Set db = Nothing
End Sub