Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2008
    Posts
    3

    Access Timestamp...

    Hi!
    I'm somewhat new to Access and have a question about creating a timestamp (three timestamps to be exact) on a form. I need to create a timestamp for when Phase 1 is complete, Phase 2 is complete and then when Phase 3 is complete. This is based off three individual text boxes that are filled from an iff statement (iff certain boxes are filled, one box says Phase 1, etc.). The code i have below works, but if Phase 1 is complete and displays 8-18-08 and then Phase 2 is completed on 8-19-08, both fields are changed to 8-19-08 instead of the Phase 1 field staying at 8-18-08.

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Me.DatePhase1Complete = "Phase 1" Then
    Me.DatePhase1Completed = Date
    Else: Me.DatePhase1Completed = ""
    End If
    If Me.DatePhase2Complete = "Phase 2" Then
    Me.DatePhase2Completed = Date
    Else: Me.DatePhase2Completed = ""
    End If
    If Me.DatePhase3Complete = "Phase 3" Then
    Me.DatePhase3Completed = Date
    Else: Me.DatePhase3Completed = ""
    End If
    End Sub



    Any ideas on how I can fix this? Thanks for your help!

  2. #2
    jya is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2007
    Location
    Chicagoland
    Posts
    109
    I assume that you want to see if the field has not already been filled out prior. This is what comes quickly to mind. Before your first If statement, insert another If statement to see if the date field is empty.

    If Len(Me.DatePhase1Completed) = 0 Then 'Check to see if date field was already entered.
    If Me.DatePhase1Complete = ...
    .
    .
    End If
    End If

  3. #3
    Join Date
    Aug 2008
    Posts
    3
    That seems like it should work, it makes sense to me anyway, but it's still doing the same...

    This is my new code:

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Len(Me.DatePhase1Completed) = 0 Then 'Check to see if date field was already entered.
    If Me.DatePhase1Complete = "Phase 1" Then
    Me.DatePhase1Completed = Date
    Else: Me.DatePhase1Completed = ""
    End If
    End If
    If Len(Me.DatePhase2Completed) = 0 Then 'Check to see if date field was already entered.
    If Me.DatePhase2Complete = "Phase 2" Then
    Me.DatePhase2Completed = Date
    Else: Me.DatePhase2Completed = ""
    End If
    End If
    If Len(Me.DatePhase3Completed) = 0 Then 'Check to see if date field was already entered.
    If Me.DatePhase3Complete = "Phase 3" Then
    Me.DatePhase3Completed = Date
    Else: Me.DatePhase3Completed = ""
    End If
    End If
    End Sub


    Did I type something incorrectly?

  4. #4
    jya is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2007
    Location
    Chicagoland
    Posts
    109
    Not sure what is going on. I would put a breakpoint at the first IF statement and step through the code. Is there a value for Len(Me.DatePhase1Completed)? If not, add a check to see if the date field is null to the If statement

    If Len(Me.DatePhase1Completed) = 0 OR IsNull(Me.DatePhase1Completed) Then

    I am not positive, but you might be able to shorten the line with

    If Nz(Me.DatePhase1Completed,0) = 0 Then

    For what it's worth.

  5. #5
    Join Date
    Aug 2008
    Posts
    3
    IsNull worked perfectly! Thanks for your help! I really appreciate it!

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

Similar Threads

  1. Replies: 2
    Last Post: 11-11-2008, 01:12 PM
  2. Replies: 0
    Last Post: 11-06-2008, 12:29 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