Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parameters need in ado

Status
Not open for further replies.

Juddy58

Technical User
Jan 21, 2003
176
AU
hello, i have a report that uses ado code to select some of its data.
currently the query in the ado module just selects all records from the table "tblEmpJob". This table contains a field "fldDate"
What i need is for only records to be selected between dates
i have created a form with two textboxes "startDate" and "EndDate" i need these to be the parameters in the ado query. I have been told i need to use a datatype "parameter" or something in the ado to be able to use these paramters.
I have been trying to refer to the textboxes directly within the sql string but keep running into errors. Im just wondering if any one could help me out, either with advice or a bit of sample code of how i would go about doing this.
Any help would be greatly appreciated as i am getting desperate to solve this problem.
Thanks!
 
hi
you dont need the parameters properties of ado, and referencing the textboxes directly is supposed to work, it just means you didnt code it right, the difference is where this code being run? on the form with the textboxes or in the report's Open event?
i'll assume it's in the report's module:
dim rs as adodb.recordset

set rs=new adodb.recordset
With Forms!FormName
rs.open "Select * From tblEmpJob Where [ldDate] Between #" & !StartDate & "# And #" & !EndDate & "#;", ...all the rest of the connection and recordset type settings...
End With

in other words: ado can accept any legal SQL statement that returns records (for the recordset object) and you dont need to use parameters.

if this doenst return results, it could mean the date format you're using is not US style (mm/dd/yy) and you'll have to add Format function to convert the date
good luck
Erez.
 
thanks mate ill try your suggestions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top