Class quirk?

  • Thread starter Thread starter MattShoreson
  • Start date Start date
M

MattShoreson

I have a module which instantiates a class to set up an ado connection.

I have a variable:
Private p_strFileName As String

I have a property:
Friend Property Let ADOFileName(ByVal strFileName As String)
p_strFileName = strFileName
End Property
Friend Property Get ADOFileName() As String
ADOFileName = p_strFileName
End Property

in the method I have:
Set p_Connection = New ADODB.Connection
p_Connection.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};"
& _
"Dbq=" & ADOFileName & ";" & _
"Extensions=asc,csv,tab,txt;"

which causes an error. However, If i hard-code the path in the
method:
strpath = "C:\WINDOWS\Documents and
Settings\username\Desktop\Folders\Quantitive\Test"
Set p_Connection = New ADODB.Connection
p_Connection.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};"
& _
"Dbq=" & strpath & ";" & _
"Extensions=asc,csv,tab,txt;"

I'm missing something here and I cant see what.
tia,
matt.
 
for the forum...

Set p_connection = New ADODB.Connection

with p_connection
provider = "Microsoft.Jet.OLEDB.4.0"
connectionstring = "Data Source=FilePath\;Extended
Properties='text;HDR=YES;FMT=Delimited'"
open
end with
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top