Results 1 to 3 of 3
  1. #1
    Dave14867's Avatar
    Dave14867 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Upstate NY
    Posts
    376

    Can I grab the ID of a Form record and use it in VBA code when running a query?

    I have a form that saves records to a table, the primary key is the ID (WorkOrderID). I have a command button on the form to run a query to append data to another table based on the inputs on the form.

    Is there a way with VBA to save the ID of the open form and use it in the query? I am not very familiar with VBA or SQL so be kind please.

    Thanks in advance.



    Dave

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    You might not need VBA, if this will do the trick.

    In the query grid design view, the criteria under WorkOrderID would be:

    Forms!YourFormName!WorkOrderID

    The form must be open with valid data when the query is invoked.
    Last edited by davegri; 08-18-2020 at 12:11 PM. Reason: clarif

  3. #3
    Dave14867's Avatar
    Dave14867 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Upstate NY
    Posts
    376
    That is awesome, I will try that davegri. I was hoping it would be something like that.

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

Similar Threads

  1. Replies: 6
    Last Post: 07-01-2015, 10:56 AM
  2. Replies: 3
    Last Post: 03-05-2015, 12:51 PM
  3. Replies: 3
    Last Post: 11-13-2014, 12:37 PM
  4. Replies: 2
    Last Post: 12-04-2013, 03:49 PM
  5. Replies: 4
    Last Post: 08-28-2013, 05:20 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