Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Docmd.TransferText command

Posted on 1998-02-25
2
Medium Priority
?
503 Views
Last Modified: 2010-05-18
Hi

i have a text file that i need to import to an existing table. i have created the import specifications and everything works fine. however, sometimes the text file has a corrupted record and the docmd.TransferText reports an error. in particular, i got error 3349 - numeric field overflow.

i just need to know if there is a way to extract the bad record and stilll complete the rest of the import process?

Keith
0
Comment
Question by:keithcsl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
cymbolic earned 40 total points
ID: 1969203
Couple of things you can do Keith, but you may not like either one.  I have automated a number of these text imports throuh Access for migration purposes. Many of the errors you get will allow you to continue, but error records will be indicated in a generated errors table.  Some fields don't make the trip, and some records may not make the trip.

What I have done is to write some simple basic file conversion/field editors to preprocess my input text files to avoid these problems. You are right, your biggest problem comes from garbaged input.  

Another possibility you might consider is to change the datatype of the column that gives you a numeric overflow, to a larger number type.  You can always modify the datatype of a column after the import is complete, but you will still loose some numeric values that overflow, when you convert from say a long to an integer, etc.

Since I do these repeatedly, I also examine the database for leftover import errors tables before each run, and delete all that show up thusly:
Dim dbs As Database, x$, y$, baldt$
 Dim tdf As TableDef, i As Integer
 Set dbs = CurrentDb
' Set dbs = OpenDatabase(x$ + "COMMON.MDB")
Application.Echo True, "Cleaning Out Database"
DoEvents
 With dbs
  For Each tdf In .TableDefs
   If InStr(tdf.Name, "_ImportErrors") > 0 Then
    x$ = "Drop Table " & tdf.Name
    dbs.Execute x$
   ElseIf InStr(tdf.Name, "MSys") = 0 And InStr(tdf.Name, "XOrg") = 0 Then
    x$ = "Delete * from " + tdf.Name
    dbs.Execute x$
   End If
  Next tdf
 End With

Note the above also empties out all tables as well, except for system tables and one table I save for cross reference lookup purposes  
0
 
LVL 1

Author Comment

by:keithcsl
ID: 1969204
auuughhh.... sounds like hard work huh? but i guess it will have to be done somehow.

i am working on an alternative way of solving this problem, maybe importing line by line and fish out the bad records. i am investigating on the speed of this approach.

i like ur idea of clening out the redundant tables. i am sure it will be useful.

Keith

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question