Results 1 to 5 of 5
  1. #1
    Bruce is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    72

    Easy one, If then ElseIf

    Access-2003. I've created a simple trouble ticket feature to an existing DB. I have a form tied to a query that returns results and displays the current record. I have a combo-box named "Status" that has 3 possible values; Open, Restored, Closed. I've got two other fields on the same form that record the "restore date and close date". I'm using VB on the status box to try and set the restore or close date automatically. Not working with my code. I've tried: After update trigger:



    If Me. Status = "restored" Then Me.restore_date = Date()
    ElseIf Me.Status = "closed" Then Me.close_date = Date()
    End If

    also tried

    If (Status = "restored") Then (restore_date = "Date()") etc...

    nutin workin

    Can someone provide this simple code for me? Thanks!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Is that space really in the first line before Status? If not, how does it work if you don't mix formats:

    Code:
    If Me.Status = "restored" Then 
      Me.restore_date = Date()
    ElseIf Me.Status = "closed" Then 
      Me.close_date = Date()
    End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Bruce is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    72
    Oops, the space was a typo. Thanks, the code worked but I would like to get both date and time. The table field value is set for General Date which includes date/time but I guess VB will only provide the date unless I specify the formatting in VB. I tried to use = DateTime but it didn't do date or time. Can you tell me how to get both date and time? Thanks again!

  4. #4
    Bruce is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    72
    Never mind. instead of using Date(), I used Now() and got both date & time.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    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: 0
    Last Post: 03-29-2011, 09:37 AM
  2. There should be an easy answer, Please Help.
    By tucker1003 in forum Database Design
    Replies: 3
    Last Post: 03-03-2011, 01:03 PM
  3. Easy question
    By Danzig in forum Access
    Replies: 11
    Last Post: 10-28-2010, 06:48 PM
  4. I know this has to be easy...
    By MelindaP in forum Access
    Replies: 7
    Last Post: 08-20-2010, 02:15 PM
  5. Probably missing something easy
    By z1efuller1 in forum Database Design
    Replies: 5
    Last Post: 11-12-2009, 11:18 AM

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