Results 1 to 4 of 4

Thread: Import from text file to field on active form

  1. #1
    Join Date
    Mar 2015
    Posts
    3

    Import from text file to field on active form

    Creating a user entry form in Access 2013. I need to add a button which when pressed imports data from a text file and places it in a single field of an ACTIVE form. The data string is 65 characters. The form itself includes both header and detail line items and requires user observation and approval before records are actually SAVED to applicable tables.

    When the information is SAVED I want to delete the text file. (This way, the equipment that creates the log/text file will create a new file with the same name for every reading it produces and each file will always ONLY have 1 record to be imported.)

    How can this be accomplished in Access?

  2. #2
    Join Date
    Jan 2015
    Location
    Birmingham AL - USA
    Posts
    7
    If that log/text file is always a single record with a single file with the same name and in the same location on your network; then the approach one might use is simply to link to it as one would link to any table, excel sheet, etc. Linking to it makes it a table from the Access perspective.

    In terms of the user interface - on your form you would could insert this table as a sub form so the user can see the display.

    There is an alternate approach to this: one can use a 'transfertext' (VBA) or 'import external data' method (found in the ribbon) - and write the field into an internal table that you have just to hold this.

    Regardless of method; part 2 is then since you say they must observe it before actually saving - then you will have a command button that triggers either an Append Query or an Update Query to write the data to its final location.

  3. #3
    Join Date
    Mar 2015
    Posts
    3
    Quote Originally Posted by CahabaData View Post
    If that log/text file is always a single record with a single file with the same name and in the same location on your network; then the approach one might use is simply to link to it as one would link to any table, excel sheet, etc. Linking to it makes it a table from the Access perspective.

    In terms of the user interface - on your form you would could insert this table as a sub form so the user can see the display.

    There is an alternate approach to this: one can use a 'transfertext' (VBA) or 'import external data' method (found in the ribbon) - and write the field into an internal table that you have just to hold this.

    Regardless of method; part 2 is then since you say they must observe it before actually saving - then you will have a command button that triggers either an Append Query or an Update Query to write the data to its final location.
    Thank you! The last thing is what command is used to delete the text file after I've read it? Else it will continually grow. (Sorry... I'm new to Access. In other software I can evaluate/shell out and use "IODEL" to delete an external text file.)

  4. #4
    Join Date
    Mar 2015
    Posts
    3
    Quote Originally Posted by Capintec2015 View Post
    Thank you! The last thing is what command is used to delete the text file after I've read it? Else it will continually grow. (Sorry... I'm new to Access. In other software I can evaluate/shell out and use "IODEL" to delete an external text file.)
    Use FileSystemObjects to delete external files: https://msdn.microsoft.com/en-us/lib...=vs.71%29.aspx

Posting Permissions

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