Results 1 to 5 of 5

Thread: Record update

  1. #1
    Join Date
    Sep 2002
    Location
    USA
    Posts
    66

    Unanswered: Record update

    Ive designed a database consists of a main form and a sub form. Ive also created an audit trial, to track down the user name who last modified the record. It works fine in record was modified in the main form but in the subform, it only works on one control. Following is the code I used:

    -----********************----
    Option Compare Database
    Private Function ModifiedInfo()
    On Error GoTo ERROR_HANDLER

    [LastModifiedBy].Value = Forms![frmMain]!lblUser.Caption
    [TimeModified].Value = TimeValue(Now())
    [DateModified].Value = DateValue(Now())

    Exit Function
    ERROR_HANDLER:
    MsgBox (Err.NUMBER & vbCrLf & Err.Description)
    Resume Next
    End Function

    ----*******************----

    Thanks,
    DD

  2. #2
    Join Date
    Feb 2004
    Location
    CT,USA
    Posts
    250
    Probably need on form & sub form a call to your function in all "on update" code sections for all controls.

  3. #3
    Join Date
    Sep 2002
    Location
    USA
    Posts
    66
    When you say update you mean I should add the code below in both BeforeUpdate and AfterUpdate of each control?

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    On Error GoTo ERROR_HANDLER
    ModifiedInfo
    Exit Sub

    ERROR_HANDLER:
    Resume Next
    End Sub

    Thanks for your reply!

  4. #4
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290
    you could also use the forms![formname].requery

  5. #5
    Join Date
    Feb 2004
    Location
    CT,USA
    Posts
    250
    Yes, and add the appropriate requery (thanks emiel) to that procedure Modified info. The procedure would make changes to the sub/forms easier in one location rather than in the several where your call to ModifiedInfo will be.

    HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •