Locking a combo box after a selection.

tim.breeding

New member
Local time
Today, 08:19
Joined
Sep 15, 2007
Messages
7
First question,

Can you put multiple commands in an event by separating with a semi-colon or something?

I'm running an event procedure in my after update of a combo box to update a table, so now I'm trying to lock the combo box after the person makes a selection.

Which brings me to my next question; how do I lock the combo box?

I tried putting [Forms]![po_req][po_number].locked = Yes in various places, but I can't seem to get it to work...

What am I missing?
 
HI,

If I understand correctly you are running an event procedure to write some data to a table using some VBA code, then you want to lock the combo box.

After the code but before the end sub line put comboboxname.locked = true and if you like comboboxname.enabled = false

This will stop it being selected or changed.

Using just one of the lines will grey the box out which you may not want, using both means it look sthe same you just can't do anuthing with it.

Have an experiment to get the effect you want.

I hope this solves your problem.

Sue
 
Tim,

You may also want to scroll the list of options (commands, properties, etc...) the VB editor gives you in the dropdown menu after your (dot) notation of the control (combo box)....

Private Sub "whatever"()
me.controlname.(DROPDOWN LIST TO SCROLL)
End Sub
Can you put multiple commands in an event by separating with a semi-colon or something?
Yes, put as many as you want. To write many, use a WITH block...
Code:
WITH controlname
  me.controlname., etc....
  me.controlname., etc....
END WITH
 
Unlock

I can get the object to lock or disable, but I'm trying to unlock/enable the control on new records....

I tried

If [Forms]![po_req]![po_number] = "" Then

[Forms]![po_req]![po_number].Locked = False

End If

I tried in the in Current_Form, Before_Update, Got_Focus... nothing works.. is my line structured correctly?
 
If Me.NewRecord then
[Forms]![po_req]![po_number].Locked = False 'or Me.[po_number].Locked = False
End If
 
If Me.NewRecord then
[Forms]![po_req]![po_number].Locked = False 'or Me.[po_number].Locked = False
End If

And Wazz's code, would go in the form's On Current event.
 

Users who are viewing this thread

Back
Top Bottom