Error Query HDR=No Text File

adygelber

New Member
Joined
May 22, 2012
Messages
30
Hi guys!

I don't manage to figure it out a "no value given for one or more required parameters" error on this code:

VBA Code:
    Const INPUT_PATH As String = "C:\Input\"
    Dim ConnTXT As New ADODB.Connection
    Dim QryTxtRec As New ADODB.Recordset

    ConnTXT.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & INPUT_PATH & ";Extended Properties='text;HDR=NO;IMEX=1;FMT=Fixed'"
    '-----
    QryTxtRec.Open "SELECT F1 as Col1 FROM FILE1.txt", ConnTXT, adOpenStatic, adLockReadOnly, adCmdText
    '-----
    With ThisWorkbook.Sheets(1)
        .Cells.ClearContents
        '-----
        .Range("A2").CopyFromRecordset QryTxtRec
    End With

Can someone help me with the correct syntax?

NB: if I use * instead of "F1 as Col1" it works well but tbh I would have liked to have something like "F1 as Col1, F2 as Col2,..."

Cheers,
Adrian
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
I forgot to say that I am using a Schema.ini like this:


VBA Code:
ColNameHeader=False
Format=FixedLength
MaxScanRows=0
CharacterSet=OEM
DateTimeFormat=YYYY-MM-DD
Col1= "Col1Name"          Long   Width  5
Col2= "Col2Name"           Long   Width  5
Col3= "Col3Name"         Char   Width 13
Col4= "Col4Name"           Char   Width  9
Col5= "Col5Name"         Char   Width  4
 
Upvote 0
What if you use the headername instead of "F1"?
 
Upvote 0
The column names are specified in the schema.ini so you should use those = Col1Name etc.
 
Upvote 0
Solution

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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