ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run Query statement in Excel (https://www.excelbanter.com/excel-programming/277247-run-query-statement-excel.html)

LSB[_2_]

Run Query statement in Excel
 

I was trying to find a record in the Access database from
my excel sheet. I manage to connect to the database
successfully and come out with the query string. but when
i run the code I can't find the record from the database,
in fact the record is in. In the database, the data type
for each field a
Field Datatype
Counter Text
Date Date/Time
Volume Number
Unit Price Number

Below is my code:
-----------------------------------------------------------
Set db = OpenDatabase("D:\Profiles\csl096c\My
Documents\Personal\OwnFiles\db1.mdb")
Let strQueryString = "SELECT * FROM Sell " & _
"WHERE Counter LIKE '" & strCounter & _
"' AND Date LIKE '" & strDate & _
"' AND Volume = " & Val(strVolume) & _
" AND [Unit Price] = " & Val(strUnitPrice)

Set rstSell = dbKlse.OpenRecordset(strQueryString)

-----------------------------------------------------------

can somebody please point out to me what possible i did
wrong or i didn't do. Please help. Many Thanks in advance..

Thanks,
SB


All times are GMT +1. The time now is 10:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com