Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2004
    Posts
    35

    Unanswered: formatting in vba?

    formatting in vba? I have the following code which places values in a table to keep track of changes made (tblPAIRSCHANGES). Sometimes only one field is changed and sometime multiple fields are changed. When it writes this info to the new table (tblPAIRSCHANGES), it makes a new line for each change. Is it possible to make it put all changes in one line?

    Private Sub FIELDNAME_AfterUpdate()
    Dim db As Database
    Dim rs As Recordset
    Set db = CurrentDb()
    Set rs = db.openrecordset("Select*from[tblPAIRSCHANGES]")
    rs.AddNew
    rs![FIELDNAME] = FIELDNAME.OldValue
    rs![FIELDNAME] = FIELDNAME.Value
    rs![DATE] = Now()
    rs.Update
    I

  2. #2
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    You couldn't know how many pairs you would have to save. So you would have to save space in a record for the maximum number of pairs there could be. Doing so would not be very good database design. Another way you can keep the changes 'together' is to assign a ChangeID to each change. I am assuming you are keeping track of changes to a record. I would set a variable during the On Current event of the form. Then save that variable with every change that was made. The variable could be set with a combination of the User ID and the time stamp.

    So when user 101 modified the record the variable might be:
    10120041123135543

    101 + YYYYMMDD + HHMMSS

    If you save this value when the user moves to the record it should be unique.

  3. #3
    Join Date
    Jun 2004
    Posts
    35

    DCKunkle, could you explain a little further?

    I really appreciate your help, but I'm really new to VBA and was wondering if you could explain your answer a little more. I already have a time stamp on this code... would I just have to update that?

Posting Permissions

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