SQL String Used for Recordset from CSV File

Snailspace

Board Regular
Joined
Jan 28, 2009
Messages
56
I think I may have bitten off a bit more than I can chew here.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
I’m trying to create a SQL string to pull in information from two csv files.<o:p></o:p>
The following works as [Acc No], [Doc No] are in the Open_Invoices file and [Due_Date] is only in the Disputed_Invoices file.<o:p></o:p>
Rich (BB code):
'works on both files<o:p></o:p>
'    SQL_OpenItems = "SELECT [Acc No], [Doc No], [Due_Date]" & _<o:p></o:p>
'                            " FROM Open_Invoices.csv, disputed_invoices.csv" & _<o:p></o:p>
'                            " WHERE [Acc No]='" & UCase(frm1_AccMain.txtAccNo.Value) & "'"<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
However if I try to use joins, or query fields with the same name I’m struggling to get a code that works. I guess it doesn’t like the additional “.” Between the file name & the csv part.<o:p></o:p>
Rich (BB code):
‘errors<o:p></o:p>
'SQL_OpenItems = "Select [Acc No], [Doc No],[Due_Date] " & _<o:p></o:p>
'                " FROM open_Invoices.csv LEFT JOIN Disputed_Invoices.csv " & _<o:p></o:p>
'                " ON open_Invoices.[Doc No] = Disputed_Invoices.[Inv_No]" & _<o:p></o:p>
'                " WHERE [Acc No]='" & UCase(frm1_AccMain.txtAccNo.Value) & "'"<o:p></o:p>

Thanks for your time.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,224,521
Messages
6,179,289
Members
452,902
Latest member
Knuddeluff

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