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!

Database in VBA always returns 0 records.

Status
Not open for further replies.

countdrak

Programmer
Jun 20, 2003
358
US
I am writing a small VBA application for out ERP package. I have to query a databse in VBA to get a result set. I have two order numbers that I compare in my query. I dont know why but query always returns 0 records. I dont know if my "" are wrongly placed or its a diffirent issue.

Here is my code.

qry$ = "SELECT OEORDHDR_SQL.ord_no, OEORDHDR_SQL.shipping_dt FROM OEORDHDR_SQL WHERE OEORDHDR_SQL.ord_no >= " & macForm.StartingOrderNo.Text & " AND OEORDHDR_SQL.ord_no <= " & macForm.EndingOrderNo.Text & ""
RS.Open qry$



macForm.StartingOrderNo.Text and macForm.EndingOrderNo.Text are the two fields holding the Order Numbers. OEORDHDR_SQL.ord_no is a 8 char field in a SQL db.

I can only access the .Text property of the macForm.StartingOrderNo and macForm.EndingOrderNo not the .Value property.

Any help will be appreciated. Thanks.
 
Try

qry$ = "SELECT OEORDHDR_SQL.ord_no, OEORDHDR_SQL.shipping_dt FROM OEORDHDR_SQL WHERE OEORDHDR_SQL.ord_no >= '" & macForm.StartingOrderNo.Text & "' AND OEORDHDR_SQL.ord_no <= '" & macForm.EndingOrderNo.Text & "'"
RS.Open qry$

That makes four '
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top