Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2002
    Location
    Kansas City
    Posts
    103

    Unanswered: Changing form control type using code builder.

    Is it possible, and if so, how can I change the property type of a form control (from List Box to Combo Box) and the underlying row source thru the code builder 'on exit'?
    For example, I would like form control B to display as a list box with data from a table unless the value in form control A is Null, in which case I'd form control B to display as a combo box with a value list that the user can select from.

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Quote Originally Posted by JamesB
    Is it possible, and if so, how can I change the property type of a form control (from List Box to Combo Box) and the underlying row source thru the code builder 'on exit'?
    For example, I would like form control B to display as a list box with data from a table unless the value in form control A is Null, in which case I'd form control B to display as a combo box with a value list that the user can select from.
    I think you can do that in this way, but you can put both on your form, hide one and unhide the other, if your condition was satisfied, then unhide the hidden one and vice versa

  3. #3
    Join Date
    Jun 2002
    Location
    Kansas City
    Posts
    103
    Thanks for the suggestion. I was, however, trying to display information in both fields/controls. 'On entering' form control A, the user would have a combo box with drop down of employee ID's to select from. 'On exit', the ID will become criteria in a query and populate control B which is employee name along with other info elsewhere. Form control B would function as a list box in this instance. If however, the use enters control B first, the opposite would occur. Control B would be set to a combo box 'On Entry' and would function as a drop down with names. 'On Exit, the name would be used in a query as criteria instead of employee ID. At this point form control A would be set to a list box and display the appropriate employee ID. I'm trying to figure out the code which will change the form control property from a list box to a combo box and change the underlying data.

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    no can do according to my a2k help:
    The ControlType property can only be set by using Visual Basic in form Design view or report Design view, but it can be read in all views.

    ...but can't you achieve a similar effect by .locked or .enabled or both?

    izy


    LATER: forget locked/enabled - it's a good solution to a totally different problem. sorry
    Last edited by izyrider; 08-20-04 at 12:07.
    currently using SS 2008R2

  5. #5
    Join Date
    Jun 2002
    Location
    Kansas City
    Posts
    103
    Thanks for the response. I just came across the bad news as well in an Access developers handbook. I will just take a different approach and use the enabled/locked settings that you both suggested.

  6. #6
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    Just a thought

    Could you have both type of controlls on the form and use the visible property in code to display whichever you want, depending on the circinstances ?

    MTB

  7. #7
    Join Date
    Jun 2002
    Location
    Kansas City
    Posts
    103
    Well, rather than changing the form control type, which I now know is an impossibility, I will minipulate the data queries behind the row source. If the user 'enters' control B, they'll get a drop down with all employee names and when they 'exit' the employee selected will become the criteria in another query and populate the ID in control A. The opposite will happen if the touch control A first.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •