Share via

MS Access VBA / SQL Import Error

Anonymous
2013-08-06T11:39:25+00:00

I am writing an SQL in VBA for a  text (.CSV) import into MS Access, currently i am testing it on one field which contains text and numbers, however the after running the following statement the numbers come in and the text doesnt't.

CSV File INfo -

field IMA contains data such as e.g. 8959 and 3SD87 - These are reference numbers (duplicates etc)

The CSV is comma delimited and has no text qualifiers.

HEre is the VBA code i am using

Dim str As String

str = "INSERT INTO [TEMP] ([IMA]) " & _

         "SELECT cstr([IMA]) FROM " & _

         "[Text;FMT=Delimited(,);HDR=YES;CharacterSet=437;DATABASE=C:\Documents and Settings\Desktop\Processed Files].[D1.csv]"

Debug.Print str

DoCmd.RunSQL str

however if i used the text import wizard and declare the field as text it comes in fine.

any ideas on how i can alter this statement to have the same result.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Anonymous
    2013-08-06T13:17:03+00:00

    Same issue occurs with transfertext, all of the "3SD57" References are excluded from the Import.

    The table i am import them into has no field restriction and the field is already descripbed as Text

    All other fields work except for this one.

    Was this answer helpful?

    0 comments No comments
  2. ScottGem 68,830 Reputation points Volunteer Moderator
    2013-08-06T12:59:46+00:00

    You can still use a TransferText and prompt for the filename first.  You are going to have to do that anyway.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2013-08-06T12:08:45+00:00

    No its not always going to have the same name or same location and table as i want to keep it dynamic.

    Was this answer helpful?

    0 comments No comments
  4. ScottGem 68,830 Reputation points Volunteer Moderator
    2013-08-06T11:59:52+00:00

    Is the file always going to have the same name and location? If so, I would just link to it or Do a TransferText, then Append.

    Was this answer helpful?

    0 comments No comments