Results 1 to 2 of 2
  1. #1
    jquickuk is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2009
    Posts
    4

    Importing Txt file via Vb

    Afternoon all.

    I have a large .txt file which is Fixed width. I had created an Import spec and works fine.

    I have 7 files for each day of the week sent to me on a Monday.

    The problem I have is I need to import these files one by one and have someway of entering the date of the file for each of those records.



    I have created a VB script which does exactly the same thing as the import wizard but I need to adapt it so it will prompt to enter the date of the file and add that to each of the records that have been imported.

    Code:
     
    Dim ImportFileName As String
    Dim strFilter As String
    Dim strInputFileName As String
    strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.txt")
    strInputFileName = ahtCommonFileOpenSave( _
                    Filter:=strFilter, OpenFile:=True, _
                    DialogTitle:="Please select an input file...", _
                    Flags:=ahtOFN_HIDEREADONLY)
                    
    ImportFileName = strInputFileName
    DoCmd.TransferText acImportFixed, "OR96 Import specification", "cancellations", strInputFileName
    Something like this.
    1. Asks user for date of file
    2. Import the records from that file in table 'cancellations'
    3. Add the value from step 1 to the field 'Cancel Date' for only those records imported

    Hope I have explained myself in a way you guys can understand

  2. #2
    Join Date
    Feb 2009
    Posts
    14
    How about something like this.

    Step 1
    Create a dialog to prompt the user for the date (MsgBox maybe?).
    Store it in a string.

    Execute steps 2 & 3 that you have described above to import a text file.

    New step 4:
    Execute a Query to UPDATE the table where you just imported the data to set the Cancel Date filed from the string in Step 1.

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

Similar Threads

  1. Importing file into Access
    By jquickuk in forum Import/Export Data
    Replies: 1
    Last Post: 03-23-2009, 09:18 PM
  2. Issues with dating when importing excel file
    By Lainie in forum Import/Export Data
    Replies: 0
    Last Post: 01-22-2009, 10:50 AM
  3. Upload file inside .mdb database file
    By havish in forum Access
    Replies: 0
    Last Post: 07-30-2008, 07:35 AM
  4. 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
  5. How do you export a file with a unique file name
    By Budman42 in forum Import/Export Data
    Replies: 1
    Last Post: 10-15-2006, 06:10 PM

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