GrandMasterTuck
In need of medication
- Local time
- Today, 10:03
- Joined
- May 4, 2013
- Messages
- 129
Hi folks. Here's an interesting situation, and I'm wondering if there's an easy solution that I'm not thinking of...
I'm building a 'string assembler' form that allows the user to select items from several combo-boxes, and the resulting values get 'assembled' or concatenated together to form a single string of text. I have attached an example database to this post so you can see what I'm talking about.
It's a relatively simple process, except for when I throw in a curve ball. To wit: I'd like to have a freeform text box elsewhere on the form wherein the user can supply a string of their own. In my combo boxes, I want the list of possible values from which they select to be comprised of the values in the underlying table AND that value the user supplies in the text box.
I'd also like that string assembler box to auto-update the assembled string with the new TextBox value if the user changes it.
In other words, I'd like for the TABLE that contains the COMBO-BOX's available value choices to also include a REFERENCE to the TEXT BOX on that form's value, too, but I DO NOT want to hard-code this value into the assembler. I'd like to store a REFERENCE to the TextBox in the table, in addition to storing straight-up VALUES.
Any ideas on how to accomplish that? As with most of my other questions, this is just an EXAMPLE of the usage of this code, and in no way represents what I ACTUALLY PLAN to use it for, so, if you don't mind, please spare me questions about WHY I want to do this. I get a lot of good replies when I pose questions, but I also get a lot of people that want to criticize my decision making, and they say things like "I don't understand why you would do this that way, it makes no sense!" ...and that doesn't help me solve a procedural conundrum. There are many uses of this kind of thing for me, and knowing how to properly code a column reference and store it in a table so it may be called and executed later using any sort of query or VBA would be massively helpful to me in several areas of more than one of the databases I'm building...
EDIT: Think of it another way... let's say I want to run a line of SQL using VBA, and it's an INSERT INTO statement. But I want to be able to DYNAMICALLY change the source columns using ComboBoxes on a form. So instead of this:
...I want to supply the DESTINATION column names dynamically, using three combo boxes called Combo1, Combo2 and Combo3. In each ComboBox are three selectable values, "Col1", "Col2" and "Col3". My code would be SOMETHING like this:
...which means that, if I set Combo1 to Col3, Combo2 to Col1 and Combo3 to Col2, the resulting executed code would be:
See what I'm trying to do? I'm trying to assemble EXECUTABLE CODE using COMBO BOXES that reference a TABLE that stores PARTS OF THE CODE in the table. Like I'm trying to assemble a line of VBA code using bits of the code stored in a table and 'assembled together' with combo boxes on a form.
Is that possible?
I'm building a 'string assembler' form that allows the user to select items from several combo-boxes, and the resulting values get 'assembled' or concatenated together to form a single string of text. I have attached an example database to this post so you can see what I'm talking about.
It's a relatively simple process, except for when I throw in a curve ball. To wit: I'd like to have a freeform text box elsewhere on the form wherein the user can supply a string of their own. In my combo boxes, I want the list of possible values from which they select to be comprised of the values in the underlying table AND that value the user supplies in the text box.
I'd also like that string assembler box to auto-update the assembled string with the new TextBox value if the user changes it.
In other words, I'd like for the TABLE that contains the COMBO-BOX's available value choices to also include a REFERENCE to the TEXT BOX on that form's value, too, but I DO NOT want to hard-code this value into the assembler. I'd like to store a REFERENCE to the TextBox in the table, in addition to storing straight-up VALUES.
Any ideas on how to accomplish that? As with most of my other questions, this is just an EXAMPLE of the usage of this code, and in no way represents what I ACTUALLY PLAN to use it for, so, if you don't mind, please spare me questions about WHY I want to do this. I get a lot of good replies when I pose questions, but I also get a lot of people that want to criticize my decision making, and they say things like "I don't understand why you would do this that way, it makes no sense!" ...and that doesn't help me solve a procedural conundrum. There are many uses of this kind of thing for me, and knowing how to properly code a column reference and store it in a table so it may be called and executed later using any sort of query or VBA would be massively helpful to me in several areas of more than one of the databases I'm building...
EDIT: Think of it another way... let's say I want to run a line of SQL using VBA, and it's an INSERT INTO statement. But I want to be able to DYNAMICALLY change the source columns using ComboBoxes on a form. So instead of this:
Code:
dbs.Execute " INSERT INTO tblCompletedString " _
& "(Col1, Col2, Col3) VALUES " _
& "([String1], [String2], [String3]);"
dbs.Close
...I want to supply the DESTINATION column names dynamically, using three combo boxes called Combo1, Combo2 and Combo3. In each ComboBox are three selectable values, "Col1", "Col2" and "Col3". My code would be SOMETHING like this:
Code:
dbs.Execute " INSERT INTO tblCompletedString " _
& "([Combo1], [Combo2], [Combo3]) VALUES " _
& "([String1], [String2], [String3]);"
dbs.Close
...which means that, if I set Combo1 to Col3, Combo2 to Col1 and Combo3 to Col2, the resulting executed code would be:
Code:
dbs.Execute " INSERT INTO tblCompletedString " _
& "(Col3, Col1, Col2) VALUES " _
& "([String1], [String2], [String3]);"
dbs.Close
See what I'm trying to do? I'm trying to assemble EXECUTABLE CODE using COMBO BOXES that reference a TABLE that stores PARTS OF THE CODE in the table. Like I'm trying to assemble a line of VBA code using bits of the code stored in a table and 'assembled together' with combo boxes on a form.
Is that possible?
Attachments
Last edited: