Results 1 to 5 of 5
  1. #1
    aldridge_p is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    12

    Inserting date into another field based on a true condition

    Hi, hoping someone can help with this one..



    I have a form with some fields.

    When one of the fields, which happens to be a combo box, is populated with one of several values I want the following to happen...

    Insert todays date into another field on the record. I'm thinking it should be fairly simple, but my VBA is rusty.

    I have the following, feel free to tell me that what I have is stupid..

    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    On Error GoTo BeforeUpdate_Err
        ' Set bound controls to system date and time.
        IIf [Status] = "Done by Katie" Or "Done by Tanya", [Process_Complete_Date] = Date
        
      
    BeforeUpdate_End:
        Exit Sub
    BeforeUpdate_Err:
        MsgBox Err.Description, vbCritical & vbOKOnly, _
            "Error Number " & Err.Number & " Occurred"
        Resume BeforeUpdate_End
    
    End Sub
    Thanks for any ideas

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    20,827
    More like


    Code:
    If Me.[Status] = "Done by Katie" Or Me.[Status] = "Done by Tanya" Then
      Me.[Process_Complete_Date] = Date
    End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    48,658
    Alternatives, although the multi-line If is most preferred.

    Me.[Process_Complete_Date] = IIf([Status] = "Done by Katie" Or [Status] = "Done by Tanya", Date, Null)

    If Me.[Status] = "Done by Katie" Or Me.[Status] = "Done by Tanya" Then Me.[Process_Complete_Date] = Date
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    aldridge_p is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    12

    Your my hero

    Paul, yet again you've come up with the goods, your a legend, Thanks!Thanks to you too June!Pat

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    20,827
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 3
    Last Post: 01-02-2012, 07:48 PM
  2. Replies: 1
    Last Post: 10-25-2011, 09:47 PM
  3. Replies: 2
    Last Post: 07-07-2011, 08:25 AM
  4. Start and Stop times where condition true
    By cheshire_smile in forum Queries
    Replies: 3
    Last Post: 07-05-2011, 09:59 PM
  5. Replies: 1
    Last Post: 02-06-2011, 06:36 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
  •  
Tech Forums: Microsoft Office Forums