vba code to talk to access - Mind blank!

jparfitt87

New Member
Joined
Jul 13, 2012
Messages
23
hi all!

i can't seem to find the answer i'm looking for and i can't for the life of me remember the code i need.
Basically, I'm having an excel file retrieve data from Access via VBA code:

Sqlstr = "SELECT ID, Record_Date, Request_Type, Policy_Number, Customer_Name, Amount, CSR, TL "

Sqlstr = Sqlstr & "FROM Tbl_Requests "

Sqlstr = Sqlstr & "WHERE Completed = FALSE and Pending = False and Declined = False and Request_Type = & Chr(34) & Refund & Chr(34) "

Sqlstr = Sqlstr & "ORDER BY Record_Date, Record_Time"

It's the highlighted bit that i can't figure out, when I debug.Print it returns request_type as "" or & Chr(34) & Refund & Chr(34).

Please help :(
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Chr34 is ", maybe you mean '

SELECT ID
, Record_Date
, Request_Type
, Policy_Number
, Customer_Name
, Amount
, CSR
, TL
FROM Tbl_Requests
WHERE Completed = FALSE
and Pending = False
and Declined = False
and Request_Type = 'Refund'
ORDER BY Record_Date, Record_Time
 
Upvote 0
You are missing a ".
Code:
Sqlstr = Sqlstr & "WHERE Completed = FALSE and Pending = False and Declined = False and Request_Type = '" & Refund & "'"
 
Upvote 0

Forum statistics

Threads
1,224,884
Messages
6,181,555
Members
453,053
Latest member
Kiranm13

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top