Results 1 to 8 of 8
  1. #1
    mlm61477 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    4

    Question Set Value of TextBox(different value than cmbx) based on yes/no Combo Box

    I have a yes/no combo box, default value set to yes. After that value is updated, I want the value of a text box to be a decimal value.



    Example: if combo box = yes, then text box = .02, if combo box = no, then text box = 0

    I think I can do this with a macro in the after update of the combo box but I'm not sure about the syntax.

    This is on one form built off one table. The text box is not on the form, just the combo box.

    please help!

    Matt

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    If the text box is not on the form, then where is it?

  3. #3
    mlm61477 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    4
    it's in the table that the form is built off of. I can put in on the form but I don't want/need it there. I just need it to store the value other than the Yes/No of the combo box. There are several of these yes/no combo boxes and each one will have a specific value. I will then add all the values up and show them in a grand total box on the form.

  4. #4
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    I see two options:

    http://www.techonthenet.com/access/f...anced/case.php

    or

    http://www.techonthenet.com/access/f...ed/if_then.php

    Personally, I would put the text box on the form for ease of programming. If you don't want it visible, then in the properties under format, change visible to NO.

    Alan

  5. #5
    mlm61477 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    4
    I tried your suggestion and it didn't work. It changes the combo box to "true", which is not an option. It should be yes or no. Nothing shows up in the text box either.

    Code that I tried:

    If me.combobox = "Yes" Then
    me.textbox = ".02"

    ElseIf me.combox = "No" Then
    me.textbox = "0"

    EndIf


    I was thinking that it should be something similar to a setvalue macro where the setvalue item = textbox and the expression = If (combobox = yes, then .02, otherwise 0).

  6. #6
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    I got it to work using Select Case. See attached.

  7. #7
    mlm61477 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    4
    I think I see the difference. I created a yes/no combo box in design view of the table. You have them both as text boxes then created a combo box on the form based off a query of table 2. I will adjust mine to do the same and let you know how that works out. Thank you for the help.

  8. #8
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    Happy that you got it figured out. One of the flaws in Access is it lets you build combo boxes in Tables. Any good developer will not do this. Here is a short read on why you shouldn't. Once you are aware, you will find that things may move smoother for you.

    http://access.mvps.org/access/lookupfields.htm

    Good Luck

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

Similar Threads

  1. Replies: 17
    Last Post: 12-20-2011, 04:36 PM
  2. Unable to populate textbox based on listbox
    By marcustofeles in forum Forms
    Replies: 21
    Last Post: 10-24-2011, 07:18 AM
  3. Input Value based on another textbox value
    By dude19 in forum Access
    Replies: 2
    Last Post: 06-30-2011, 03:48 PM
  4. Replies: 2
    Last Post: 09-17-2010, 09:53 AM
  5. Replies: 3
    Last Post: 02-10-2010, 07:29 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