Import txt file

Jose

Registered User.
Local time
Today, 19:21
Joined
Nov 3, 2010
Messages
31
I am trying to run this code from an access db to import a txt in a different one. Do you know why the below code doesnt work?

Thanks

Jose

Private Sub Command0_Click()
Dim cnn As ADODB.Connection
Dim strConn As String
Set cnn = New ADODB.Connection
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source= C:\Users\Desktop\Backend.mdb;"
cnn.Open strConn
DoCmd.TransferText , acImportDelim, , "Lamda","C:\Users\documents\Lamda.txt"

cnn.Close
Set cnn = Nothing
End Sub
 
probably because your data source has the wrong address? I don't think in any windows version, there is a desktop address that is: "c:\users\desktop"
 
Try removing the comma before acImportDelim
, acImportDelim

Do you get an error message?
 
Guys,

I sorted out.. I came up with this is code

Private Sub Command2_Click()
Dim cnn As ADODB.Connection
Dim strConn As String
Set cnn = New ADODB.Connection
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source= C:\Users\Manuel\Desktop\Backend.mdb;"
cnn.Open strConn
DoCmd.TransferText acImportDelim, "Lamda-Import", "Lamda", "C:\Users\Manuel\Desktop\Lamda.txt", -1
cnn.Close
Set cnn = Nothing
End Sub

I just need to come up with a message box that will appears when the file has been finished uploaded.
 

Users who are viewing this thread

Back
Top Bottom