# Database Discussions > Microsoft Access >  Import from text file to field on active form

## Capintec2015

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?

----------


## CahabaData

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.

----------


## Capintec2015

> 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.)

----------


## Capintec2015

> 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

----------

