Combo Box question ?

  • Thread starter Thread starter TonyB
  • Start date Start date
T

TonyB

Hi,
I have a combo box in a form, which has an ID as a controlsource, which is
also a PK in another table. Using an SQL query it looks up the name
corresponding to that key in another table.
When I open the form it displays the name looked up from the current record
ID which is fine.As I step through records the combo box reflects the
current name for the current ID correctly.
However I want to prevent this value from being altered while the record
being displayed is an existing record, and only being changed if it is a new
record.
Is there a programmatic or other way of preventing the user being able to
drop down the list in the combo box which I can then control via the
NewRecord property ? Or maybe display a text box if not new record, and
combo if it is a new record, or if this is not possible prevent changes in
the combo box being stored unless it is a new record ?
TIA
Tony
 
You could try putting some code in the form's OnCurrent event that would
lock the combo box unless it's a new record.

Private Sub Form_Current()
If Not Me.NewRecord Then
Me.Combo7.Locked = True
Me.Combo7.Enabled = False
Else
Me.Combo7.Enabled = True
Me.Combo7.Locked = False
End If
End Sub



...
 
Back
Top