Results 1 to 7 of 7
  1. #1
    trolleri is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    43

    Trouble programming combo boxes

    Question 1:
    I wish to program a combo box to have sentences as predefined answers, and then save the answers as a numeric value in the table instead of the shown sentence. E.g. a question: "What sex?", with predefined answers: "Male; Female", stored as "1" or "2" in the table. Found this (link) guide, but how do I set the combo box to store the answers in a table without a Control Source set for the combo box? I have hundreds of combo boxes spread out on different forms, all forms having its own table as the record source.


    Question 2:
    Some questions have been answered with different units. E.g. "How many times a day/ a week / a month / a year did this occur?”. I would like the answers to be stored in one specific unit, for easy comparison. Is it possible to make the form calculates the value, and stores it for the unit "a year"?


    Question 3:
    I have a yes/no question followed by a text box "if yes, then describe in text". Is it possible to grey-out the text box, if "no" is selected in the previous question?

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Question 1: when you drag a combo box to add to your form, select the 2nd option to "Type the values I want". Set no. of columns to 2.
    Type the values 1 and 2 in Col1.
    Type Male and Female in Col2.
    On the last page of the wizard, select your fieldname to store the value.
    Set column widths to 0;3 ( Setting the first column to zero will hide it from user.) The table will now store 1 for Male and 2 for Female.
    If combo box's row source is a table or query, you have to set up the "bound column" cautiously. You can always hide a column by setting the width of corresponding column to zero.
    question2 : Not clear to me
    Question 3 : In the afterupdate event of "yes/no" field, use the Me.yourTextBoxName.Enabled=False to grey it out. Better option is to disable the text box initially, set the default value of yes/no field to "no" and enable the text box if answer is "yes".

  3. #3
    trolleri is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    43
    Thank you for the answer!
    The solution sounds perfect, I will work on it tonight

    Quote Originally Posted by amrut View Post
    question2 : Not clear to me
    What I meant was this: The surveys have been answered in the paper form, and now needs to get stored into records in the database. Some questions have been answered by the subjects as "I have this experience X times a week", but other subjects answered the same question with "...X times per year."

    It is easy to multiply the X from the first subject into a full year, but tidy for the end-user to do this by hand for all subjects. Is it possible to make a form that can handle different units, and then calculate them into one specific unit before saving the data into the record, ensuring that the data have the same unit.

  4. #4
    trolleri is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    43
    Your solution for problem #1 works like a charm - thank you


    I have some trouble implementing your solution for problem #3. Followed your instructions, and used the code:
    Code:
    Me.MyComboBoxName.Enabled=True
    but I got the error cannot find the object 'Me.'

    Both the combo box with the "after update"-event, and the combo box I want to enable, is located in the same subform. So I tried this:
    Code:
    [forms]![MySubformName]![MyComboBoxName].Enabled=True
    But again I got the error cannot find the object 'forms!MySubformName!MyComboBoxName.'

    The subform is put inside a tabbed control on the main form, so I finally tried this:
    Code:
    [forms]![MyFormName]![MySubformName]![MyComboBoxName].Enabled=True
    and again got the error cannot find the object 'forms!MyFormName!MySubformName!MyComboBoxName.'


    Is this happening because it is not a text box, but a combo box?

  5. #5
    trolleri is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    43
    Anyone who sees the error?

    You can dowload my database here: to begin! 55 - CRF4 nye felter.zip

    And find instructions on how to get to the specific combo box here:
    Click image for larger version. 

Name:	unlocking combo box.jpg 
Views:	7 
Size:	116.7 KB 
ID:	11773

    I have tried the codes mentioned in my previous post, but still cannot get the first column of combo boxes under the headline “The Symptom Checlist” to unlock the second column of combo boxes (greyed out), when selected a value not “0”. I get the error messages as described in the post above.

  6. #6
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Check this http://access.mvps.org/access/forms/frm0031.htm for syntax for sub forms

  7. #7
    trolleri is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    43
    Quote Originally Posted by amrut View Post
    Check this http://access.mvps.org/access/forms/frm0031.htm for syntax for sub forms
    Wow it worked, had to use [brackets]

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

Similar Threads

  1. Replies: 9
    Last Post: 06-04-2014, 10:45 AM
  2. Trouble with Disappearing Boxes
    By ineedaccesshelp in forum Forms
    Replies: 10
    Last Post: 11-28-2012, 11:54 AM
  3. Cascading Combo Boxes trouble
    By Monterey_Manzer in forum Access
    Replies: 4
    Last Post: 09-13-2012, 11:06 AM
  4. Replies: 11
    Last Post: 03-20-2012, 08:55 AM
  5. Trouble with Combo Box
    By djclntn in forum Forms
    Replies: 16
    Last Post: 02-21-2012, 05:59 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