Run Time Error 3265

rnutts

Registered User.
Local time
Today, 00:04
Joined
Jun 26, 2007
Messages
110
I have a form (frmEnquirySearch) which is based upon a query (qryEnquirySearch), the form is used to search Enquirys and I have a unbound control on the form. This was referenced in the criteria section of the query where I had a field called search that basically created a string of all the searchable fields using [fieldname1]&[fieldname2] etc. The user inputs what they want to filter on and clicks a cmdbutton which basically requeried the form and displayed results accordingly. All was working well until I was as for a filter on one control on the form. This meant I needed to set the values for the criteria by field in the query. Searching forums I have the code below to set the criteria in the query using vba but I am getting the Run time error 3265 Item not found.
I have checked the spelling and when I go to vba debug I hover over the .Parameters and I get the message that it cannot find ("CustOrdNo").
I have tried (CustOrdNo), ("tblprojectdetails.CustOrdNo") but still get the same missing message
I have also posted the SQL for the query

Code
Private Sub cmdSearch_Click()
Dim QD1 As DAO.QueryDef
Dim RST1 As DAO.Recordset
QD1 = CurrentDb.QueryDefs("qryEnquirySearch")
QD1.Parameters("custordno") = 1234
Set RST1 = QD1.OpenRecordset
QD1.Close
exit_handler:
Exit Sub

Err_handler:
MsgBox Err.description
Resume exit_handler
End Sub

CustOrdNo is a text field so 1234 should be ok, I did also try "1234" to see if that was the problem
I have trimmed some lines out of this so the overall thing may not work, but I cannot get past this point.

Query SQL
SELECT tblsurveyenquiry.enquirynumber, tblsurveyenquiry.address1, tblsurveyenquiry.client1, tblsurveyenquiry.description, tblsurveyenquiry.enqdescription, tblsurveyenquiry.ProjectTitle, tblProjectDetails.CustOrdNo, [tblsurveyenquiry]![enquirynumber] & [tblsurveyenquiry]![address1] & [tblsurveyenquiry]![client1] & [tblsurveyenquiry]![client2] & [tblsurveyenquiry]![description] & [tblsurveyenquiry]![enqdescription] & [tblsurveyenquiry]![projecttitle] & [CustOrdNo] AS Search
FROM tblsurveyenquiry LEFT JOIN tblProjectDetails ON tblsurveyenquiry.enquirynumber = tblProjectDetails.EnquiryNumber
ORDER BY tblsurveyenquiry.enquirynumber DESC;

Any help is greatfully received

Richard
 

Users who are viewing this thread

Back
Top Bottom