Can you add a combo box after click a button to a form?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ifclick
    New Member
    • Mar 2015
    • 7

    Can you add a combo box after click a button to a form?

    I am new to access but i have a little bit of SQL knowledge. I am just wondering if you can add a combo box in a running form without going to design view.

    The idea is "I want to borrow an multiple asset from asset table and save the Barcode ID of asset to Borrow Table." However, in a form you are limited on the combo box that you input in design.

    Is there any possible way in VBA or SQL query to do this task?
  • jforbes
    Recognized Expert Top Contributor
    • Aug 2014
    • 1107

    #2
    Unlike .Net, you can't add controls at Runtime in Access.

    You might get what you want by adding some controls and setting the Visible property to False. Then in code, you can set the Visible property to True. Also in code, you can set the ControlSource of a control and it will set the binding on the fly giving you a Late Binding scenario.

    Comment

    • ifclick
      New Member
      • Mar 2015
      • 7

      #3
      I found how to make the combo box invisible and visible once you choice an input.



      However, I am not familiar with late binding in VBA.

      Comment

      • jforbes
        Recognized Expert Top Contributor
        • Aug 2014
        • 1107

        #4
        If you have things working for you the way you want, that is great.

        The Late Binding Scenario I mentioned isn't a truly Late Binding, but it is very similar and seemed to be the most descriptive way to explain it with out getting too wordy.

        The wordy version is that you can place a Control on a Form during design time and leave the Control Source blank. This Control is then considered Unbound (no Control Source). Then after the Form is running, the Control Source can be set in VBA and Access will data bind the Control to the Database field and it will work. Which to me, is pretty amazing. You can then change the Control Source again and again and Access will continue to work. You can even change the Record Source of the Form along with changing the Control Source and Access will continue to work.

        This technically isn't Late Binding, probably more of a Data Binding in Code, but again, I was trying not to be too wordy.

        Comment

        Working...