Hi I have a date range query that works fine when run directly but when I try to run it from form it gives me error - too few parameters.
I know I have parameters in criteria but I don't know how to add it on form button.
here is the criteria in query
Between [Forms]![Dupl]![txtStartDate] And [Forms]![Dupl]![txtEndDate]
here is the code on commad button in form (partly)
Set rs = db.OpenRecordset("SELECT Date, TowerTopic, Items, Media, Audience FROM FilterDate")
As long as you have, on form Dupl, txtStartDate and txtEndDate, and there is data in both of those fields, you should be fine. In order for it to work with this criteria, the form must be open with data in the fields. If it still gives you the too few parameters issue, you might have more criteria in another field in the query that it is looking for. That is hard to determine without seeing the WHERE in the SQL.
Check out the attached image. It doesn't look like I have any other parameters in the Query. The date is there in the text field and still it say "Too few parameters. Expected 2"
Any more suggestions please. Stuck here since morning.
It is expecting you to put the date in those two fields. It is looking for a form named "Dupl", I am assuming you already have this form created? And on this form it is looking for two text box fields which you use as your criteria. If those two fields are empty, you will get an error. The form needs to be open, and the fields filled in before the query is run.
yes, I agree with you and that is why I have attached the image in my last post that shows the Dupl form is open and the two date range fields are showing the dates. The filterdate window is showing the date criteria and still having this problem.