Results 1 to 11 of 11
  1. #1
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146

    VBA to Append table not working

    Everything seems to be set up right but no changes to table and no errors popping up.



    Click image for larger version. 

Name:	VBA Pic.png 
Views:	28 
Size:	30.9 KB 
ID:	51522
    Attached Thumbnails Attached Thumbnails Picture1.png  

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Have you advanced beyond that? The SQL hasn't run yet in your image. Presuming so, use this to test the SQL in a new query and see if you get an error:

    https://baldyweb.com/ImmediateWindow.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Accidentally duplicated post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why are you saving user name instead of ID? Same could be asked about Description - do you have a set of standardized descriptions?

    You have actually run the command and not just stopped as shown in image?

    Description is a reserved word. Really should not use reserved words as names. Try enclosing Description in brackets: [Description]. http://allenbrowne.com/AppIssueBadWord.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146
    Yes, I have run the whole code with no results or errors. I'm trying to capture changes of records to a separate table for tracking.

  6. #6
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146
    Here is the result.

    Click image for larger version. 

Name:	Pic 2.png 
Views:	28 
Size:	5.1 KB 
ID:	51524

  7. #7
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Does this work?
    Code:
    Public Function LogIt (sDescription as String,sNote as String, sUser as String
    With CurrentDb.OpenRecordset("tblLogLocal", , dbSeeChanges)
            .AddNew     ' Add new record.
                !Description = sDescription
                !Note = sNote
                !User = sUser
            'End If
            !UpdatedOn = Now() 'a (new) time stamp field       
            .Update     ' Save changes.
            .Close
    End With
    End Function
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by mainerain View Post
    Here is the result.

    Click image for larger version. 

Name:	Pic 2.png 
Views:	28 
Size:	5.1 KB 
ID:	51524
    Did you try running that SQL in a new query?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146
    Thanks for the replies. I will have to follow up at a later time.

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Quote Originally Posted by mainerain View Post
    I'm trying to capture changes of records to a separate table for tracking.
    Doesn't matter, my point is you are still saving text data when you should probably be saving ID. User is who made the change - save their ID not their full name.

    Review http://allenbrowne.com/AppAudit.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146
    Sorry for such a delay in responding. Life is busy.

    So, I decided to add a field, [User_ID], to the form so when I copy the record to an Audit Table it will contain who made the changes. It also is used to show who made the last change on the form.

    No reserved words used.
    Not text, but ID for reference in Audit table.

    Again, thanks for everyone's input.

    Final code:

    Code:
    Private Sub Form_AfterUpdate()Dim S As String
    
    
            On Error Resume Next
            DoCmd.SetWarnings False
    
    
            S = "INSERT INTO tblProjectDetailAuditTrail SELECT * FROM tblProjectDetail " & "WHERE ID=" & ID
            DoCmd.RunSQL S
    
    
            DoCmd.SetWarnings True
    End Sub
    Attached Thumbnails Attached Thumbnails VBA Code.png  

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

Similar Threads

  1. Append Query not working
    By emma313823 in forum Queries
    Replies: 2
    Last Post: 01-20-2021, 01:14 PM
  2. Append query not working
    By rayted in forum Queries
    Replies: 1
    Last Post: 03-05-2018, 05:22 AM
  3. Replies: 19
    Last Post: 10-03-2017, 09:10 AM
  4. Append query not working
    By seth.murphine in forum Queries
    Replies: 5
    Last Post: 04-20-2012, 06:41 PM
  5. Paste Append not working
    By martinshort in forum Access
    Replies: 3
    Last Post: 01-20-2012, 07:45 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