Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Oct 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Import .txt to string (2000)

    Good afternoon...I am trying to read in a fixed length string from a .txt file and assign it to a variable using the following command...I continue to get an error message "expected function or variable". Any help would be appreciated. Thanks

    Dim BARCODE As String

    BARCODE = (DoCmd.TransferText(acImportFixed, "TextImportTest", "TextImportTest", "D:TextImportTest.txt", 0))

    Msgbox "Barcode on package is " & BARCODE

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import .txt to string (2000)

    DoCmd.TransferText is not a function. It imports a text file into an Access table; you can then use DAO or ADO to loopt through the records of the table.

    If you want to read individual lines from a text file, you should either use the old-fashioned Basic instructions Open and Input or Line Input, or else use FileSystemObject and its OpenTextFile method, together with Read or ReadLine.

  3. #3
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Richland, Washington, USA
    Posts
    407
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Import .txt to string (2000)

    If you opt for using the FileSystemObject, be sure to select Tools...References... (from the VBA Editor window) and check the "Microsoft Scripting Runtime" reference so that this object is accessible.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import .txt to string (2000)

    Good point. BigSteve may have more questions, depending on the method he wants to use.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •