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

    If/then text box

    Hello,


    I am creating a metrics form for work Requests for Service. One of the fields is time spent, with a combo box with values from 15 minutes to more then 4 hours hours.

    My question is how do I get a text box to appear to allow me to type in a custom value if more then 4 hours is selected?

    Can anyone give me some help?

    Thank you.

  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
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    depends on how your time spent field is set up, if it is a combo box and it's just a list of values you would use something like the ON EXIT property of your time spent field

    Code:
    if TIMESPENT = "4 or more hours" then 'You would substitute your actual text label here
      TIMESPENTEXTRA.visible = true
    else
      TIMESPENTEXTRA = null
      TIMESPENTEXTRA.visible = false
    endif
    where TIMESPENTEXTRA is the name of your field you want to toggle visibility on. Just make sure you clear the value out if it exists already.

    if your time spent is a calculated value it depends on how it's stored, if it's a decimal then it would be something like

    Code:
    if TIMESPENT >= 4 then 'You would substitute your actual text label here
      TIMESPENTEXTRA.visible = true
    else
      TIMESPENTEXTRA = null
      TIMESPENTEXTRA.visible = false
    endif
    and so on, you would have to modify this if you were storing the time spent as a date/time value or if you were pulling the timespent from a table with a unique identifer and you wanted pull the text string of an unbound column you would use TIMESPENT.column(x) where x would be the 0 index based column number from your combo box (in access all list boxes/combo boxes start with column 0, so your second column is actually column(1)).

  4. #4
    PRHoff is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2015
    Posts
    7
    I'm getting an error message on this.
    My question is, how do I set it up to be able to type in a custom value if more then 4 hours is selected in the combo box?

  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
    Getting an error on what exactly? What is the error? Where do you have the code?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    PRHoff is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2015
    Posts
    7

    Combo Box to display popup for custom text

    Hello,
    for a form measuring metrics I have a combo box stating time spent on a request for service.
    It has time measurements going from 15 minutes to 4 hours. It also has a selection that says "More then 4 hours".

    My question is, when I select More then 4 hours, how do I get a comment box to pop up so I can enter in the custom time.
    Example: "More then 4 hours selected" (ideally comment box pops up allowing me to type in 5.5 hours and click okay)
    anyone have any ideas for this?

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    what is the rowsource of the combo box? cut and paste what's in the ROW SOURCE property. Your statement really depends on how that list is set up as noted in my first post.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Combobox is bound to text type field?

    Maybe in the combobox AfterUpdate event.

    If Me.comboboxname Like "More*" Then
    Me.comboboxname = InputBox("Enter elapsed time.")
    End If

    If you want to do calcs with this field, should be a number type and enter the same units for all records (either in minutes or decimal hours).
    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.

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Threads merged since they were essentially the same topic.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    PRHoff is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2015
    Posts
    7
    row source is "15 Minutes";"30 Minutes";"45 Minutes";"1 Hour";"1.5 Hours";"2 Hours";"2.5 Hours";"3 Hours";"3.5 Hours";"4 Hours";"> 4 hours"

  11. #11
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    from my original post:

    Code:
    if TIMESPENT = "4 or more hours" then 'You would substitute your actual text label here 
        TIMESPENTEXTRA.visible = true 
    else   
        TIMESPENTEXTRA = null   
        TIMESPENTEXTRA.visible = false 
    endif
    You have to substitute in your actual value where you see I have "4 or more hours" and you have to insert your actual field names where I have TIMESPENT and TIMESPENTEXTRA

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Do you plan to do calculations with that data, such a Sum of the time for a group of records?
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 11-21-2013, 10:07 AM
  2. Replies: 10
    Last Post: 03-22-2012, 07:00 PM
  3. Replies: 6
    Last Post: 07-18-2011, 12:56 PM
  4. Tool Tips popup text
    By pkstormy in forum Code Repository
    Replies: 6
    Last Post: 09-02-2010, 05:50 PM
  5. Replies: 2
    Last Post: 10-09-2009, 07:34 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