Hi All,
I am having an issue with a parameter query, let me try and explain...
I have a table (tblsitelogs) which contains records with dates on. I want to be able to query between 2 dates (from a form which the user specifies), and then export the data from the query, to an excel spreadsheet.
I browsed earlier and found this code to help me export the query to excel: http://www.databasejournal.com/features/msaccess/article.php/3563671. I am experienced in VB (although reletively new to Access), so I have adopted the code and tested it, and it works fine when run by itself.
Here is the query (qryReport)..
When I then run this code
I get an error on the bottom line, I get the error:
"Too few parameters. Expected 2".
I have researched and this appears to be an almost normal issue because of the query being a parameter-based query.
I've tried typing in the query in SQL, into VB and then running that instead, but it doesn't seem to filter, it will just display all results.
Feel free to ask more questions into this, I am probably only touching the surface of the problem here. Any help greatly appreciated!
Thanks,
Taz
I am having an issue with a parameter query, let me try and explain...
I have a table (tblsitelogs) which contains records with dates on. I want to be able to query between 2 dates (from a form which the user specifies), and then export the data from the query, to an excel spreadsheet.
I browsed earlier and found this code to help me export the query to excel: http://www.databasejournal.com/features/msaccess/article.php/3563671. I am experienced in VB (although reletively new to Access), so I have adopted the code and tested it, and it works fine when run by itself.
Here is the query (qryReport)..
Code:
"SELECT tblSiteLog.ExchangeCode, tblSiteLog.ExchangeName, tblJobDetails.Phase, tblSiteLog.JobType, tblSiteLog.JobItem, tblSiteLog.Engineer, tblSiteLog.LogEntryDate, tblSiteLog.Result, tblSiteLog.EntryDetails, tblSiteLog.EnteredBy" & _
" FROM tblJobDetails INNER JOIN tblSiteLog ON tblJobDetails.JobID = tblSiteLog.JobID" & _
" WHERE (((tblSiteLog.LogEntryDate) Between " & txtStartDate & " And " & txtEndDate & "));"
When I then run this code
Code:
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("qryReport", dbOpenSnapshot)
I get an error on the bottom line, I get the error:
"Too few parameters. Expected 2".
I have researched and this appears to be an almost normal issue because of the query being a parameter-based query.
I've tried typing in the query in SQL, into VB and then running that instead, but it doesn't seem to filter, it will just display all results.
Feel free to ask more questions into this, I am probably only touching the surface of the problem here. Any help greatly appreciated!
Thanks,
Taz