Results 1 to 8 of 8
  1. #1
    NaomiC is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    27

    Date Stamp from a combo box after update event, depending on selection in combo box

    Hello,



    I would like to select a "not-scheduled" status from a combo box and have a text box auto populate today's date, however I would like it to be blank if it is "Scheduled". I have tried using the code below and it works on all statuses, I just need it to be Null for "Scheduled". Can someone help me modify?

    Code:
    Private Sub Scheduled_DropDown_AfterUpdate()
    If Not IsNull(Scheduled_DropDown) Then
    Me.NOT_Scheduled = Date
    ElseIf Me.Scheduled_DropDown = "Scheduled AA'" Then
    Me.NOT_Scheduled = Null
    End If
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    Code:
    If Scheduled_DropDown = "not-scheduled" then
       NOT_Scheduled = Date
    End If
    you shouldnt have to set null. It starts null.

  3. #3
    NaomiC is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    27
    I'm sorry, I don't think I was very clear in my first post. There are 8 not-scheduled statuses that may be used in my combo box. 1 status is Scheduled AA. If I select Scheduled AA the NOT_Scheduled field needs to be blank, or if i choose one of the other 8 statuses I need the current date in the NOT_Scheduled field.

    I have also tried something like this and I get a syntax error or a run-time error '13' .

    Code:
    If Scheduled_DropDown = "cancelled" OR "declined" OR "inclement_weather" then 
       NOT_Scheduled = Date
    ElseIf Me.Scheduled_DropDown = "Scheduled AA" Then
    Me.NOT_Scheduled = Null
    End If
    End Sub

  4. #4
    NaomiC is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    27
    I still have not been able to get this to work. Any suggestions?

  5. #5
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    --- UNTESTED-----
    I added the Me and adjusted the ORs ---but it's a guess
    at what you're trying to accomplish
    Code:
    If Scheduled_DropDown = "cancelled" OR _
       Scheduled_DropDown ="declined" OR _
       Scheduled_DropDown ="inclement_weather" then 
       me.NOT_Scheduled = Date
    ElseIf Me.Scheduled_DropDown = "Scheduled AA" Then
       Me.NOT_Scheduled = Null
    End If
    End Sub

  6. #6
    NaomiC is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    27
    Hi Orange,

    Thanks! I think the OR's helped. I also removed the underscores from the status (="inclement_weather") as the space is not in the Combo box. I just thought when using VBA spaces were not allowed. For future refernece, would that rule only apply to field names?

  7. #7
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Field names and object names (Forms, reports, collections, recordsets...) should not have embedded spaces or special characters ($#@%&..etc). Use only alphanumeric and "_"(underscore) and you will save yourself from many syntax errors.
    In your example
    "inclement_weather" is a value, not a field/object name, so you can have any characters you want/need.

  8. #8
    NaomiC is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    27
    Thank you for the explanation! Have a great day!

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

Similar Threads

  1. Replies: 2
    Last Post: 10-28-2014, 03:55 AM
  2. combo box selection does not update correctly
    By mrtinmalaysia in forum Forms
    Replies: 2
    Last Post: 01-14-2013, 06:37 AM
  3. Replies: 5
    Last Post: 08-08-2012, 01:30 PM
  4. combo box selection to update form
    By sartan2002 in forum Forms
    Replies: 6
    Last Post: 02-03-2012, 01:47 PM
  5. Combo Box event based on selection
    By tobydobo in forum Access
    Replies: 52
    Last Post: 01-20-2012, 07:26 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