Results 1 to 4 of 4
  1. #1
    Ganymede is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    64

    Form Event Procedure ->Populate Table


    Say I have a forum with a date text box. I want create a table that logs if and when that field is changed. Is it possible to create an event procedure that populates a row of data on a separate table.

  2. #2
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    Why do you want to do this? Why not just have a date field in the bound table?

    Either way you can use code
    Code:
    Private Sub [event]
    Dim rs as DAO.RecordSet
    rs = CurrentDb.OpenRecordSet("TableName") 'name of table you are writing to
    rs.Fields("FieldName") = Me![formControlWithDate] 'this is the name of the control with the data you want to write in
    rs.Close
    rs = Nothing
    End Sub

  3. #3
    Ganymede is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    64
    Quote Originally Posted by nick404 View Post
    Why do you want to do this? Why not just have a date field in the bound table?

    Either way you can use code
    Code:
    Private Sub [event]
    Dim rs as DAO.RecordSet
    rs = CurrentDb.OpenRecordSet("TableName") 'name of table you are writing to
    rs.Fields("FieldName") = Me![formControlWithDate] 'this is the name of the control with the data you want to write in
    rs.Close
    rs = Nothing
    End Sub
    Thank you.

    I'm doing this because the new table won't populate with the date entered in the date field.

    So there are two tables. One table is bound to the form. That will store the date information. The second table is not bound to the form, and that's the one I want to populate with the event procedure. The second table will basically be a change log. I want to know whenever the field on the form is changed. So each time the date is changed on the form, the second table will record the time, the record entry # (from the first table), the name of the person making the change (every person who uses this database has to log in), and the new value.

    I think your coding works. Thank you again.

  4. #4
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    I see what you mean now. Makes much more sense. If anything else comes up post back.

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

Similar Threads

  1. Replies: 13
    Last Post: 09-10-2015, 03:37 PM
  2. Replies: 5
    Last Post: 04-21-2014, 12:18 PM
  3. Form Event Procedure
    By Jgk in forum Forms
    Replies: 7
    Last Post: 03-30-2014, 04:31 PM
  4. Replies: 1
    Last Post: 03-29-2014, 07:46 PM
  5. Replies: 3
    Last Post: 05-07-2012, 12:17 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