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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
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,396
Messages
6,178,398
Members
452,844
Latest member
Shebl

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