My apologies, I'm using Access what I want to do is to select a control source from within a text box. As there is no feature to do that I was wondering if there was any code to allow me to do this.
This might be what you're looking for. I've kind of knocked this up in a hurry, so suggest you experiment on a copy!
I assume:
- You've got the list appearing in the textbox ok.
- The textbox is on the same form as the field that you want to change the control source for.
I'll refer to 'textbox1' and 'field1', with 2 possible controlsources in the table, called 'ctrl1' and ctrl2'.
Make sure the textbox is unbound - it might start creating rogue records if it's a field in the table!
Place this code on for example the 'afterupdate' event for the textbox:
dim cts as string
cts = me.textbox1.value
field1.controlsource = cts
This code will modify the control source for field1 to the exact text in textbox1, so make sure your list of choices are valid. if it is not, you should see something like '#name?' appear in the controled field.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.