Results 1 to 5 of 5
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need SQL or DAO Code? (a2k (9.0.6926) SP-3 Jet 4.0 SP-7)

    I have the following code to change UserID and DateUpdate when a record in form is changed as an audit trail.

    Private Sub Form_BeforeUpdate(Cancel As Integer)

    Me.dteDateUpdate = Date
    Me.strUpdateID = NetUser()

    End Sub

    Both fields are in the form

    How whould I change this code to use SQL or DAO to perform the same function if the two fields are not in the form?

    Thanks, John

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Need SQL or DAO Code? (a2k (9.0.6926) SP-3 Jet 4.0 SP-7)

    I don't see why you would want to set these fields in another table than the record source of the form. Problem is, which record do you want to update?

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need SQL or DAO Code? (a2k (9.0.6926) SP-3 Jet 4.0 SP-7)

    I want to update the same table that the form is bound to, however the dteDateUpdate and strUpdateID fields are not on the form.

    If the operator changes any form information I want the record the current user id and date in the table.

    Thanks, John

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Need SQL or DAO Code? (a2k (9.0.6926) SP-3 Jet 4.0 SP-7)

    If the fields are in the record source of the form, it doesn't matter that there are no controls bound to them on the form. You can still update them as in the first post in this thread. Make sure to use Me. and not Me!

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need SQL or DAO Code? (a2k (9.0.6926) SP-3 Jet 4.0 SP-7)

    That makes it easy

    Thanks

Posting Permissions

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