Results 1 to 7 of 7
  1. #1
    fuxy is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    4

    Importing Txt file to Access

    Hi there, I am a newbie at access and attempting to import txt into access. I am currently working with a database that was built by another developer and am struggling to find how the import process that was previously built works.



    The code behind the button:

    Private Sub ImportOracle_Click()
    Dim namefile As String
    Dim nameInput As String
    Dim lngAnswer As Long
    On Error GoTo errHandler:
    'when error is ahppeninig on the statement below then the program will jump to
    ' errHandler: lable which is located in the very bottom of this module
    lngAnswer = MsgBox("Are you sure that data in Oracle.txt is updated?", vbYesNoCancel, "Append Record?")
    Select Case lngAnswer
    'if yes then import the file
    Case vbYes
    namefile = "R:\Quality Management\DailyError\Oracle.txt"

    DoCmd.TransferText acImportDelim, "Oracle Raw Spec", "Oracle_Raw_Data_Table", namefile

    DoCmd.OpenQuery "Oracle_Error_Daily_Import", acViewNormal, acReadOnly
    DoCmd.Requery (Forms!DailyMenu!List13)
    'if not then do nothing
    Case vbNo, vbCancel
    'do nothing
    End Select
    'set warning to true and get out from vba
    DoCmd.SetWarnings True
    Exit Sub
    errHandler:
    MsgBox "Import Failed", vbOKOnly
    DoCmd.SetWarnings True
    End Sub


    I'm not sure where to begin in identifying where the problem lies.

    Appreciate the help!

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    you forgot one thing here, bud.

    what's the problem?

  3. #3
    fuxy is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    4
    Sorry about that.

    So when I click on the button it says Import failed.

    I have also created an import spec for the text file as it is delimited by '~'

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by fuxy View Post

    I have also created an import spec for the text file as it is delimited by '~'
    so does that mean you've solved the issue?

  5. #5
    fuxy is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    4
    Quote Originally Posted by ajetrumpet View Post
    so does that mean you've solved the issue?
    The text file is delimited by ~ and I am trying to import it into access.. I am using the import function in access to delimit the text file and append it to a table within access. The issue now lies within access and getting the text file imported in to access. I am using a button to append the text file data to a table. But whenever I go to click on the button,it fails.

  6. #6
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by fuxy View Post
    The text file is delimited by ~ and I am trying to import it into access.. I am using the import function in access to delimit the text file and append it to a table within access. The issue now lies within access and getting the text file imported in to access. I am using a button to append the text file data to a table. But whenever I go to click on the button,it fails.
    so that's absolutely redundant. do this first: change the options in vba for error trapping and click "BREAK ON ALL ERRORS". do that and tell us what line gets highlighted when you push the button.

  7. #7
    fuxy is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    4
    Here is the error that i get:

    Run-time error '3349':

    You cannot record your changes because a value you entered violates the settings defined for this table of list (for example, a value is less than the minimum or greater than the maximum). Correct the error and try again.

    And when I go in to the debugger, the below line is highlighted.

    DoCmd.TransferText acImportDelim, "Oracle Raw Spec", Raw_Data_Table", namefile

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Need help importing CPxml file into an access database
    By Chirila in forum Import/Export Data
    Replies: 3
    Last Post: 03-06-2011, 12:29 PM
  2. Importing a text file to access
    By Navop in forum Access
    Replies: 2
    Last Post: 11-11-2010, 07:15 PM
  3. Replies: 1
    Last Post: 07-31-2010, 08:04 AM
  4. Importing file into Access
    By jquickuk in forum Import/Export Data
    Replies: 1
    Last Post: 03-23-2009, 09:18 PM
  5. Importing a tab delimited file into access table - please he
    By championss in forum Import/Export Data
    Replies: 0
    Last Post: 10-29-2006, 02:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums