Import a text file using VB

J

Jack

I have been trying to import a text file to a table. The
file was saved using the exort wizard from the oriningal
table. There is only one field in this table that I set up
just to test the module. I am using Access 2000 and a VB
module. This is the line of code:

"DoCmd.TransferText acImportDelim, "TblTest Import
Specification", "tblTest", "A:\tblTest.txt", 0"

I got the error "Field F1 doesn't exist...". I then went
to microsoft web and found the error message and opened
the import wizard, clicked advanced and named the field.
Then I got the error "Field F2 doesn't exist...". I went
back to the wizard and saw that I hadn't checked
the "Skip" box next to the other six fields. I did
everything over again and tried to "Save as" and keep
getting an error message "An error occured trying to save
export/import specification". I even closed & reopened the
database and tried again. I also renamed it by adding a 1
to the end of the filename but it still would not work.

How do I set the specification?

Thank you,
Jack
 
J

Jack again

-----Original Message-----
I have been trying to import a text file to a table. The
file was saved using the exort wizard from the oriningal
table. There is only one field in this table that I set up
just to test the module. I am using Access 2000 and a VB
module. This is the line of code:

"DoCmd.TransferText acImportDelim, "TblTest Import
Specification", "tblTest", "A:\tblTest.txt", 0"

I got the error "Field F1 doesn't exist...". I then went
to microsoft web and found the error message and opened
the import wizard, clicked advanced and named the field.
Then I got the error "Field F2 doesn't exist...". I went
back to the wizard and saw that I hadn't checked
the "Skip" box next to the other six fields. I did
everything over again and tried to "Save as" and keep
getting an error message "An error occured trying to save
export/import specification". I even closed & reopened the
database and tried again. I also renamed it by adding a 1
to the end of the filename but it still would not work.

How do I set the specification?

Thank you,
Jack
.
I got the above problem solved but now I get the "error
number 0". I think this is a generic error number when the
cuase of the error is unknown.

I am getting very frustrated with what should be a simple
task and should not cause so many problems. What am i
doing wrong?

Thanks, Jack
 
D

Dirk Goldgar

Jack again said:
I got the above problem solved but now I get the "error
number 0". I think this is a generic error number when the
cuase of the error is unknown.

I am getting very frustrated with what should be a simple
task and should not cause so many problems. What am i
doing wrong?

Error 0 means no error has occurred. The most common reason for "Error
0" to be displayed is code that falls through into the error-handler,
similar to this:

Sub DoSomething()

On Error GoTo Err_DoSomething

' ... miscellaneous code that doesn't cause an error ...

Err_DoSomething:
MsgBox "Error " & Err.Number

End Sub

Because there's no Exit Sub statement before Err_DoSomething, execution
falls through into the error-handler and a message is displayed even
though no error has occurred.

Another time I've seen "Error 0" is when a real error had been raised,
but the error-handling code performed some operation that cleared the
error before attempting to display it.
 
M

Marshall Barton

-----Original Message-----
Jack said:
I got the above problem solved but now I get the "error
number 0". I think this is a generic error number when the
cuase of the error is unknown.

I am getting very frustrated with what should be a simple
task and should not cause so many problems. What am i
doing wrong?

Error 0 indicates that there is no error!

People see that when they forgot to exit the procedure
before the start of the error handling code at the end of a
procedure. The basic outline of a procedure with error
handling is along these lines:

Sub whatever( . . .
. . .
On Error GoTo ErrHandler
. . .
ExitHere:
Exit sub

ErrHandler:
MsgBox Err.Number & " - " & Err.Description
Resume ExitHere
End Sub
 

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

Top