Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change a Combo Box into a TextBox

Status
Not open for further replies.

wdennis

Technical User
May 31, 2000
9
US
I have a Combo Box with two columns, an autonumber field(hidden) and a text field, which is bound on the autonumber field.&nbsp;&nbsp;There are six items to choose from in the list.&nbsp;&nbsp;If the 1st item is chosen, a dialog box opens to accept user input to replace what is in the text field of the Combo Box.&nbsp;&nbsp;This value will be different every time it's filled in.&nbsp;&nbsp;Any other choice on the list is to be displayed as it appears.&nbsp;&nbsp;Is it possible to change the combo box into a text box and have it accept this new data just for this one choice while still leaving it as a combo box for the other five choices?&nbsp;&nbsp;I tried using this code, and got a message telling me to switch to design view if I need to change the ControlType property.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me.cboDisposition.ControlType = acTextBox<br><br>Any ideas?<br>Thanks, wdennis
 
No, <br>But you can your make your combo box accept new values.<br>Or have a separate text box which holds whatever is selected in the combo.<br><br>So you have a combo and a text box side by side<br>The combo is clicked and an option is picked then the user keys in something when prompted this something goes in the new text box which it's control source is a field on your table.<br>Now if the user picks something in the combobox and it does not prompt then just put the standard value in the Textbox<br>using the combo's After Upadte event:<br><br>Me!Text1 = combo1.column(1)<br><br>Promted one<br>Me!Text1 = Inputbox(&quot;Enter value&quot; ....<br><br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
Hi Walt and Doug, I'm basically just trying to save form real estate.&nbsp;&nbsp;I've got a combo box with two columns.&nbsp;&nbsp;The bound column is an autonumber field from the lookup table and it's hidden in the combo box.&nbsp;&nbsp;The visible field is text.&nbsp;&nbsp;The user can choose one of five items from the list.&nbsp;&nbsp;The first item is &quot;project&quot;.&nbsp;&nbsp;I'm trying to make it possible for the user to enter a project number like &quot;0041658A&quot; to replace the word &quot;project&quot; and then display that number in the combo box.&nbsp;&nbsp;If one of the other items is selected from the list, I'd like it to be displayed as it first appears in the combo box.<br><br>Here's the code I've used in the BeforeUpdate event of the combo box.<br><br>Const conFormName As String = &quot;fdlgProjectNumber&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>If Me.cboDisposition = 1 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Open dialog form for user input<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenForm conFormName, WindowMode:=acDialog<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'User has clicked OK on dialog form<br>&nbsp;&nbsp;&nbsp;&nbsp;If IsLoaded(conFormName) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Transfer user input to main form<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me.cboDisposition=Forms.fdlgProjectNumber.txtProjNum<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>End If <br><br>I'm getting an error message that says I'm violating a validation rule.&nbsp;&nbsp;I assume it's the autonumber field that's causing the problem.&nbsp;&nbsp;Can I specify that the text entered from fdlgProjectNumber.txtProjNum is a replacement for the second column of cboDisposition and not the bound column?<br><br>Since I cannot change the combo box to a text box the only other solution I can think of is to use two controls (a combo box and a text box) and make the text box visible in the combo's place only if the project number is being entered by the user.<br><br>I hope this better explains what I'm trying to do.&nbsp;&nbsp;I do appreciate your responses. Thanks so much, wdennis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top