Results 1 to 4 of 4
  1. #1
    shane201980 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    25

    Programming to change Combobox to Textbox on the fly

    Ok, so I'm a little new to Access and I'm in way over my head.

    Here's my problem:



    I'm creating a special contact database, and then i'll have a form to add/edit/etc. My problem comes when I want to add information fields. I need 3 information fields, the first one will be a combobox that will recieve it's information from a table, and users can select their option. The second box will need to adjust based on the first box information.... example: I select "Dogs" in the first box, the second box will be a combobox that reads another column in the table with options (this is easy). But if you select the "Other" option in the first combobox, i need to have the second box be a textbox that I can fill in what ever information i need. The 3rd field will follow similar to the second, so if I can solve this I should be able to program the rest.

    To sum it up, i need the 2nd box on my form to vary as either a combobox or a textbox based on the information selected in the 1st box.

    I'm not sure if this possible, but any help would be appreciated. I haven't exactly started the form or database yet until I can solve this problem; trying to think ahead before I hit my road blocks.


    Thanks,

    Jason

  2. #2
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    Switching a control between two types could be done "on the fly" I think, but not easily, because you have to actuallly modify the form.

    What you might do is have two controls, one a combo box, the other a textbox, and use code to control which one is visible based on the selection in the first combo box - use the After Update event. Both controls can have the same table field as the Control Source.

    If the user selects "Other", make the text box visible and the combo invisible - anything else is the reverse.

    HTH

    John

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    I think you'll have to include the same code in the Form_Current event, in order for the right type of Control to be displayed, when moving from Record-to-Record.

    And John was correct, I believe; in order to actually change the type of Control, you'd have to Open the Form in Design View, make the change, then go back to Form View. IMHO, his solution is the better approach.

    Linq ;0)>

  4. #4
    shane201980 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    25
    Ok, great! I've got the basic idea now, and i think I can put it together. It's definetly not a simple layout, but I'm glad there may be a work around for me.

    I'll try and post how it goes.

    Thanks a million!

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

Similar Threads

  1. Replies: 5
    Last Post: 04-19-2012, 09:35 AM
  2. On click textbox inserts value back on combobox
    By whitelockben in forum Forms
    Replies: 2
    Last Post: 10-09-2011, 05:23 AM
  3. change a combobox value depending on another
    By emadaldin in forum Access
    Replies: 3
    Last Post: 01-17-2011, 01:06 PM
  4. Replies: 1
    Last Post: 03-18-2009, 12:30 AM
  5. change() on the textbox
    By skywalker in forum Forms
    Replies: 0
    Last Post: 03-01-2009, 01:28 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