+ Reply to Thread
Results 1 to 7 of 7

Placing the controls dynamically in the userform and populating the values from AccessTBL

  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Placing the controls dynamically in the userform and populating the values from AccessTBL

    Hi Guys

    I am building a project using Excel as a frontend and Access as a backend. There is just one userform and the user needs to select the values in 3 comboboxes.( first select value in Combobox1 , then combobox2 will appear and then user will select the value from combobox2, then combobox3 will appear and user will need to select the value from combobox3) and based upon the values selected , there will be only one record in the Access table. Now based upon that corresponding controls will appear in the userform and the corresponding values will be populated in those controls. The new requirements in this are as below:

    1.It should be dynamic – that means as we add or delete fields in the table (or even rename them) this needs to recognise that and dynamically produce a control for each field.
    2.Linked to the above the system needs to recognise the data type for each field and again dynamically display an appropriate control. (Checkbox or Textbox)

    I have never worked with dynamic controls so will need your help in this. So if in the table there is checkbox then checkbox will appear in the userform and if the field's data type in Text then textbox will appear in the userform and the values should be populated in the controls on the userform.

    Any help will be much appreciated.

    Thanks

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Placing the controls dynamically in the userform and populating the values from Access

    Couple of questions:
    1.It should be dynamic – that means as we add or delete fields in the table (or even rename them) this needs to recognise that and dynamically produce a control for each field.
    How is the code supposed to know what sort of control you want? Checkbox, textbox, combobox etc?

    Moreover however, this sounds like your database isn't set up properly. You don't dynamically add fields and change field names in a database, the structure is generally static, you just add records - I'd start by looking at your database schema and you may find you don't need to do this

  3. #3
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Placing the controls dynamically in the userform and populating the values from Access

    Hi Kyle

    The table has already been built and have been used for quite a long time now. Now there is a new user interface and for that new project we need to refer to same table but we might need to add/delete or rename fields in that which will be done manually. But when the user form is shown then it should reflect all those field name and its contents based upon the 3 comboboxes values selected.

    And also there will be either Textbox or checkbox controls which will be displayed dynamically and not any combobox . So we need to check if DataType is "Yes/No" then put checkbox for that field in the form and if the datatype is "Text" then put textbox for that field.

    I hope it make sense. Many Thanks

  4. #4
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Placing the controls dynamically in the userform and populating the values from Access

    Hi there

    I have already built the code that will create the controls dynamically on the userform . The values get populated in the controls using vba too. But now I have to perform the update operation on the control values i.e if the users want to change a record then they make some changes in the values in the userform and Press Update button to save those changes. But my code is giving me an error "Field can't be changed" Can anyone please help me in this.

    Please Login or Register  to view this content.

  5. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Placing the controls dynamically in the userform and populating the values from Access

    You never, ever rename fields in a database - why would you?

    I don't really understand why you want to do it dynamically - just how many fields do you have?

    I really think you need to normalize your database - this will then make this whole thing trivial - could you post your database schema? An image would do
    Last edited by Kyle123; 11-11-2015 at 12:29 PM.

  6. #6
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Placing the controls dynamically in the userform and populating the values from Access

    Kyle, This is requirement from my Boss . He wants all the controls to appear dynamically and then we will need to update the records using vba. In future he said we will need to delete many fields from the table and add few fields or rename fields. SO I just have to work on that. No other option fomr. ((

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Placing the controls dynamically in the userform and populating the values from Access

    That's daft, it's not how databases work, they aren't spreadsheets. I wish you the best of luck

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Populating listbox values of userform dynamically in the Access table fields
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-07-2014, 06:52 AM
  2. [SOLVED] userForm -> Frame 'top' value limited. Dynamically created controls,
    By kropeck in forum Excel Programming / VBA / Macros
    Replies: 29
    Last Post: 08-19-2013, 09:04 AM
  3. Dynamically create and Place Controls such as CheckBoxes,Text-Boxes in a UserForm
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 35
    Last Post: 05-11-2011, 11:34 AM
  4. Combox Box : Populating values dynamically
    By Yuvarani in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-03-2010, 12:54 AM
  5. Dynamically populating rows according to values in another worksheet.
    By Splurd in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-20-2010, 10:38 AM
  6. Save UserForm controls values?
    By Dr.Ile in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-28-2007, 05:32 PM
  7. Creating UserForm Controls dynamically
    By MWE in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-20-2005, 12:05 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1