Run-time error '3001'

canberry

Registered User.
Local time
Today, 05:41
Joined
Sep 22, 2008
Messages
36
Could anyone help me to reslove this error. This code been working fine with previous data i loaded just now so not sure why im getting an error when all data are in the same format. I pasted my code below

Option Compare Database
Dim DB As Database
Dim GL As Recordset
Dim SQLStatement As String
Dim CC As Recordset
Dim TM As Recordset
Dim FilePath As String
Function ImportAccountMaster()
Set DB = CurrentDb
With Application.FileSearch
.LookIn = "C:\Documents and Settings\101 November 06\11082006\MCDNOW\"
.FileName = "MC*.txt"
If .Execute(msoSortByFileName, msoSortOrderAscending) > 0 Then
For i = 1 To .FoundFiles.Count
FilePath = .FoundFiles(i)
DoCmd.TransferText acImportFixed, "Account Master Export Specification", "Account Master", [FilePath]
Next i
End If
End With
End Function
Function ImportAccountMasterExt()
Set DB = CurrentDb
With Application.FileSearch
.LookIn = "C:\Documents and Settings\101 November 06\11082006\MCNOW\"
.FileName = "MC*D.txt"
If .Execute(msoSortByFileName, msoSortOrderAscending) > 0 Then
For i = 1 To .FoundFiles.Count
FilePath = .FoundFiles(i)
DoCmd.TransferText acImportFixed, "AccountMaster-ext Specification", "AccountMaster-ext", [FilePath]
Next i
End If
End With
End Function
 
DoCmd.TransferText acImportFixed, "Account Master Export Specification", "Account Master", [FilePath]
 
Is there a possiblity that this load of data has extra delimiters as part of the text? For instance, when a delimiter in a text file is the comma (,), if a row/column has an actual comma as part of the data, it will cause an error.

Try this:
Code:
Err.Clear
On Error Resume Next
DoCmd.TransferText acImportFixed, "Account Master Export Specification", "Account Master", [FilePath]
If Err <> 0 Then
MsgBox "Error: " & Err & vbcrlf & Error
End If
On Error Go To 0

Put a break on the MsgBox line and when an error occurs, single step through the code, evaluating all the variables (by mouseover or in the immediate window) until you spot a trend.
 

Users who are viewing this thread

Back
Top Bottom