problem importing Barcode

p0welly

Registered User.
Local time
Today, 07:03
Joined
Aug 26, 2004
Messages
38
Im integrated a metrologic scanpal batch barcode scanner into my application, the scanner drops a csv into my application directory, the text file is as follows.

My Text File

9794022121256032,4
9794022121256032,9
9794022121256032,3
9794022121256032,5

I then use the following sub to import the text into a table

Code:
Sub Import_DataCap()
Dim strFilter2 As String
Dim strStartDir As String
Dim varFileName As Variant

'Set filter for file dialog
strFilter2 = "Text (*.CSV)" & vbNullChar & "*.CSV" _
& vbNullChar & "All Files (*.*)" & vbNullChar & "*.*"
' Set default directory to look in
strStartDir = "C:\"

'get file path
varFileName = "c:\program files\my file location\DataCap\Import.txt"

DoCmd.TransferText acImportDelim, "", "tblImportTable", varFileName, False, ""


End Sub

My Table then contains 2 numeric fields

9.79402212125603E+15 4
9.79402212125603E+15 9
9.79402212125603E+15 3
9.79402212125603E+15 5

I need the first field to import as text, can anybody help?

Thanks in Advance
 
Hi p0welly,

Create an import specification, lets say ImportSpecs. At the begining of the import text wizard after you have selected the file check the "Advanced" button, this will allow you to play with field types. Once you have the field types correct then save it and the saved name can be used as shown bold in the example. Also use acImportFixed rather than acImportDelim

Your code would change to;

Code:
DoCmd.TransferText [COLOR="Red"]acImportFixed[/COLOR], "[B]ImportSpecs[/B]", "tblImportTable", varFileName, False, ""

Good Luck

Robert88

P.S - I used it recently myself http://www.access-programmers.co.uk/forums/showthread.php?t=98441&highlight=robert88
 
Last edited:
Perfect!

Thank you very much
 

Users who are viewing this thread

Back
Top Bottom