I have created a parameter form to run against a query. On the form I have 3 controls to enter the data for the parameter and 2 command buttons to run the query and cancel it. Within the query I reference the form in the criteria as the two following:1) Between [forms]![closedticketsparameter]![begindate] And [forms]![closedticketsparameter]![enddate] 2) [Forms]![Closedticketsparameter]![priority].
When I open the form I enter in the parameter criteria and select the OK (run query) command button. What happens next is where I am stumped. I am then asked to Enter Parameter Value: [forms]![closedticketsparameter]![begindate], then [forms]![closedticketsparameter]![enddate], then [Forms]![Closedticketsparameter]![priority].
When I debug the code, it says that this is wrong: DoCmd.OpenQuery "qry_closedticketsPARAMETER", acViewNormal, acEdit.
Any ideas on what I could have wrong. I would be happy to zip the mdb and send it, but I am not sure how that is done on this forum.
Nick, Here is the SQL, but I have also attached a zip file of the mdb. My screen is small so I never saw the "manage attachments" option. I must be one of those people help desks like to laugh about. Thanks for taking a look at this.
SELECT dbo_requests.start_date, dbo_requests.close_date, dbo_status.sname, dbo_requests.id, dbo_requests.uid, dbo_requests.title, dbo_priority.pname, dbo_categories.cname, dbo_departments.dname
FROM ((((dbo_requests LEFT JOIN dbo_departments ON dbo_requests.department = dbo_departments.department_id) INNER JOIN dbo_priority ON dbo_requests.priority = dbo_priority.priority_id) LEFT JOIN dbo_categories ON dbo_requests.category = dbo_categories.category_id) LEFT JOIN dbo_status ON dbo_requests.status = dbo_status.status_id) INNER JOIN dbo_tblUsers ON dbo_requests.rep = dbo_tblUsers.sid
WHERE (((dbo_requests.close_date) Between [forms]![frm_closedticketsparameter]![begindate] And [forms]![frm_closedticketsparameter]![enddate]) AND ((dbo_priority.pname)=[Forms]![frm_Closedticketsparameter]![priority]));
On the form, the textboxes are named other than what you're calling out in the query. On the form, they are called Text2, Text4 and Combo8, while you're query is looking for controls called begindate ,enddate and priority.
Just as a general note though, I've learned to try and avoid parameter queries. I instead try to formulate the query in VB using the controls, and then run it. For a good tutorial on this, check out Martin Green's Site.
Nick, Thanks for noticing that. I also noticed it earlier but failed to change it before I sent you the zip file. But upon fixing it, the query is still not working. It is not returning any records. I am very stumped at this point. Any other ideas?
Thanks for the VBA/SQL link. I have not worked in that area much, more so because I am intimidated by it. But I need to conquer it sometime. I will use the Martin Green's site as a start for my lessons.