block edit of form control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like a control that displays a lookup value for a user that can't be edited by the user. If I put this in a combobox, how can I block edit? I could also do DLookUp or add the lookup table to the underlying form query (which already involves at least 4 tables). What's the most efficient way to manage this?
Thanks so much. I greatly appreciate you folks that help us newbies.
JoshM
 
Hi Josh,

You can lock any control by setting it's Locked property to True - look at
the property sheet under the data Tab.

If you are going to lock the value then I don't see much point of using a
combobox - unless of course you want the user to select a value from the
combo but you want to grab a related value from the combo and display it
elsewhere on the form. This is relatively easy to do:

First make sure that the related field is included in the rowsource of the
combo and make sure that you increase the Column Count property to include
any new fields. Adjust the ColumnWidths property according to whether you
want to see the values when the combo is dropped down. Then for each related
field you want to display create a textbox. In the ControlSource of the new
textbox put

=me.MyCombo.column(3)

Then because the column property is indexed starting with 0, replace 3 with
the column number minus 1 of the field you want to display. IOW, the above
will cause the value from the 4th column to be displayed in the textbox.

Dlookups are also a way to get related information - for one field a dlookup
is not a bad way to go unless the information is already available elsewhere
(as in the related field in a combo's rowsource as described above). If you
go with the Dlookup, you will need to issue the dlookup from two events -
the Afterupdate event of whatever control has the linking information for
this field and from the Current event of the form so that the display value
of the related field matches the current record.
 
Back
Top