Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2002
    Location
    New Zealand
    Posts
    19

    Unanswered: Increment number in vb Help

    I Have a form which i want to track how many times it has been revised.
    In code I can get it to date stamp but cannot get the revision to increase.
    I am at a loose end.
    I have tried a few permutations, anyway here is the code.
    The Me![Revision] - Me![Revisio] + 1 Doen't work
    Private Sub Form_BeforeUpdate(Cancel As Integer)


    'Check if any changes have been made to the form.
    If Me.Dirty = False Then 'do nothing
    Else
    If Me![Last Change Log] = DATE Then 'do nothing
    Else
    Me![Last Change Log] = DATE
    End If

    'Check that the revision count has not already been started

    Me![Revision] = Me![Revision] + 1


    End If
    End If

    End Sub

    Can anyone suggest a better way to count that works and increments each time a revision is made.
    Thanks
    Regards
    Bill

  2. #2
    Join Date
    Feb 2002
    Posts
    403
    Private Sub Form_BeforeUpdate(Cancel As Integer)


    'Check if any changes have been made to the form.
    If Me.Dirty = False Then 'do nothing
    Else
    If Me![Last Change Log] = DATE Then 'do nothing
    Else
    Me![Last Change Log] = DATE

    'Check that the revision count has not already been started

    Me![Revision] = Me![Revision] + 1

    'Isnt this the end of the modified statement?

    End If


    End If
    End If

    End Sub

  3. #3
    Join Date
    Apr 2002
    Location
    New Zealand
    Posts
    19
    Hi
    Possibly.
    But

    Me![Revision] = Me![Revision] + 1

    Doesn't increment.
    On the first revision the feild is still blank.
    On any future updates and changes the feild still does not increment.
    If the revision is two days apart the date will change but the revision feild still remains blank.
    Hence my problem.
    Cheers
    Regards
    Bill

  4. #4
    Join Date
    Feb 2002
    Posts
    403
    If me.revision="" or Isnull(me.revision) then

    Me.revision=1

    Me.revision.refresh

    else

    Me.revision=Me.revision+1

    Me.revision.refresh

    End if

  5. #5
    Join Date
    Feb 2002
    Posts
    403
    Whoops, this is better

    If me.revision="" or Isnull(me.revision) then

    Me.revision=1

    Me.revision.refresh

    else

    Me.revision=DMax("[revision]","[myTable])+1

    Me.revision.refresh

    End if

    This will only count forward.

  6. #6
    Join Date
    Apr 2002
    Location
    New Zealand
    Posts
    19
    Thanks dynamictiger,
    Your help and responce saved me.
    I also see that microsoft reserves certain words for its own
    functions Revision seems to be one, and Date another.
    I'm no expert in VBA, more a do it and try.
    It's a job thats been thrust upon me that I accepted with open arms to advance.
    I know enough to get me into trouble.
    Thanks Again
    Regards
    Bill

Posting Permissions

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