Results 1 to 7 of 7
  1. #1
    Steenert is offline Novice
    Windows 10 Office 365
    Join Date
    May 2020
    Posts
    4

    Question Reading and using data from attachment in form

    Hello,

    For a Form to use in our change management process. We want to be able to do the following:

    1. Upload a text file in the form (This is working already).
    2. Save the data from that text file to the database.
    3. Execute a Query on this data
    4. Display the filtered data in the same form




    We want to be able to upload a text file and show certain parts of this file in the form after uploading.

    How can we achieve this? We have been googling a bit on this topic but cannot find the answers we are looking for. If needed we can incorporate external tools.

    Thanks in advance!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    so step 1 is adding the text file to the table? but step 2 would be done too.
    save the text file to the same spot everytime, like: c:\temp\myfile.txt
    link the text file as an external table
    make a query to append the external txt file to the target table (#2)
    make a select query to view the data in this txt file. (#3)
    make a form to show the data in the text file (4)

    so the steps would be:
    1 save the text file to the same file c:\temp\myfile.txt
    2. run append (import) query
    3. open form to view that data

  3. #3
    Steenert is offline Novice
    Windows 10 Office 365
    Join Date
    May 2020
    Posts
    4
    Hello ranman256,

    That sounds like a good way to do it, but I am afraid that I do not know how to code this in VBA properly. Do you happen to have an example for me to work with?
    Specifically saving the text file to the same spot every time is something I cannot seem to get done.

    Thanks a bunch in advance!

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    vba not really needed.
    manually link the text file. (build the link spec.)

    once connected, build an append query to add the text data to the target table.

    make the form to view the linked table.

    all this can be done with zero vb. Put the append query in a macro thus:
    1. save the text file
    2. run the macro

    the macro would run the append query, and open the form.

  5. #5
    Steenert is offline Novice
    Windows 10 Office 365
    Join Date
    May 2020
    Posts
    4
    Oké I got that working. But the thing that's not completely clear to me is how to have this automatically run when a user uploads the attachment in the form.

  6. #6
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    give the user a button, the button runs the macro. (import, show form)

  7. #7
    Steenert is offline Novice
    Windows 10 Office 365
    Join Date
    May 2020
    Posts
    4
    Hello,

    I am afraid that I am not able to update the existing record using an append query, whenever I try this it creates a entirely new record. I want to update an existing record, I tried using the update function instead of append, but I cannot select the table this way.

    Any ideas?

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

Similar Threads

  1. Replies: 5
    Last Post: 02-09-2015, 04:18 PM
  2. Replies: 3
    Last Post: 10-13-2014, 05:48 PM
  3. Replies: 1
    Last Post: 09-04-2014, 11:10 AM
  4. Reading and matching Data using C#
    By FuzzyPanda in forum Programming
    Replies: 1
    Last Post: 10-12-2013, 06:33 AM
  5. Export a form data with attachment
    By Gloring in forum Import/Export Data
    Replies: 1
    Last Post: 07-02-2012, 03:00 PM

Tags for this Thread

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