Results 1 to 5 of 5
  1. #1
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2003
    Join Date
    Sep 2013
    Posts
    287

    Button on form to add a record to a non-linked table


    Hey guys,

    I have a form that lists order with some of their info. When a process is complete in an outside system, the user presses the button on that record in the form. This button needs to add a record to a separate table, called "T_Invoiced". The record is merely the order number (which is on the same form as the button) and an "X" in the column called "Invoiced".

    What is the code to accomplish this?

  2. #2
    JamesDeckert is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    Salina, KS
    Posts
    262
    docmd.runsql "INSERT INTO T_Invoiced ( OrderID, Invoiced ) SELECT " & me.[field] & " AS txtOrderID, x AS inv"

  3. #3
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2003
    Join Date
    Sep 2013
    Posts
    287
    Thanks James. Tweaked that SQL line a bit and it works great.

    Next part is when that Invoiced button is clicked, I want that record to disappear. The form is built on a query that pulls records where [Invoiced] is null. I added a me.Refresh after the sql string and that didn't work. Going into design view of the form and then back to form view, the record does disappear, so the SQL and query works. Why isn't me.refresh working? What should I be doing?

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Instead of Me.Refresh, you might try Me.Requery.

    From Help:
    Refresh shows only changes made to records in the current set. Since the Refresh method doesn't actually requery the database, the current set won't include records that have been added or exclude records that have been deleted since the database was last requeried. Nor will it exclude records that no longer satisfy the criteria of the query or filter. To requery the database, use the Requery method. When the record source for a form is requeried, the current set of records will accurately reflect all data in the record source.

  5. #5
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2003
    Join Date
    Sep 2013
    Posts
    287
    Gah I tried Recalc. Didn't even know about Requery. Works like a charm now.

    Thanks!

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

Similar Threads

  1. Replies: 12
    Last Post: 12-04-2013, 06:19 PM
  2. Replies: 5
    Last Post: 11-12-2013, 12:14 AM
  3. Replies: 1
    Last Post: 06-24-2013, 11:31 AM
  4. Replies: 3
    Last Post: 08-19-2012, 12:12 PM
  5. Replies: 1
    Last Post: 03-04-2011, 08:53 AM

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