This has got to be simple...

Nightowl4933

Tryin' to do it right...
Local time
Today, 06:50
Joined
Apr 27, 2016
Messages
151
...as most things are - when you know the answer!

I have a form with a ComboBox from which users pick a value. The control source is separate from the form's data table.

I want to use a 'viewing' form so users can see everything, but not change it.

I would like to change the ComboBox to a Text Box with the value in it, but all I get is the [ID] and not the [Title].

I'm able to use If... Then... Else... based on the value of the ComboBox on the form, but I'd have to edit the code if I make any amendments to the table.

tblAuthority, [ID], [Authority]
frmViewer, txtAuthority

Thanks :)
 
Hi

If you are using a separate form that is only used for viewing from this first form, set the textbox's controlsource as Forms!MainFormName.ComboBoxName.column(1) - if the Title is the second column in the combobox
If the form is opened form multiple points, either set the textbox value after opening the viewing form OR pass the value in the forms OpenArgs property.Both of these would need some VBA. Let us know if you want to go down this route.
 
Hi
The form is used to review all records, one at a time, so I was hoping to replace the ComboBox with a TextBox purely for 'aesthetic' reasons.

When I add aTextBox to do this I get the Code rather than the Name of the Authority, so I was thinking of using DLookup rather than coding it with VBA. I just couldn't work out how!

Pete
 
I think you are confusing yourself a little. Is your combo box used by the user to select the underlying records? If so you can't really use a text box with the same functionality.

You could use a listbox but it won't work as nicely.

The third option is to set a text box with the selected combobox value on top of the combobox. When the user tabs into the text box (gets focus event) the code puts the focus on the combo box lets them make the selection and the after update on the combo box updates the textbox and moves them away from both controls.
 
Hi Pete

OK, so only 1 form in use?

txtAuthority ControlSource would be
Code:
=Dlookup("[Authority]","[tblAuthority]","[ID]=" & me.ID)
IF ID is available on frmViewer.
 
I think you are confusing yourself a little. Is your combo box used by the user to select the underlying records? If so you can't really use a text box with the same functionality.

You could use a listbox but it won't work as nicely.

The third option is to set a text box with the selected combobox value on top of the combobox. When the user tabs into the text box (gets focus event) the code puts the focus on the combo box lets them make the selection and the after update on the combo box updates the textbox and moves them away from both controls.

I probably gave the impression of confusing myself (which I'm really good at :)), but I got there in the end!

Thanks for the comments, though. They did help!
 

Users who are viewing this thread

Back
Top Bottom