Disable Combo box after select the record.

alexkong2003

Registered User.
Local time
Today, 22:51
Joined
Sep 4, 2006
Messages
95
Hi Everyone,

I want to try to restrict the user not always changing the record, so i need a Disable combo box command. And i did try it by using "Name.Enabled = False" after user select the value from the combo box, but the program won't let me do that because of the record is on focus. So what can i do? I only have an idea of after the user select the value from cbo then jump the cursor immediately to the second column, but anybody can tell me how to do that?
Thanks alot!

Regard,
alex
 
just type:

me.secondcolumn.setfocus
me.name.enabled = false
me.name.locked = true

-cacing
 
Yes! The code work. Thanks cacing.
 
You might want to put a dialog box in the code, to confirm that your user has selected the value he intended, prior to locking up the Combo Box.
 
Sorry for the noob question. Where do I go to insert this code? Thanks guys
 
Sorry for the noob question. Where do I go to insert this code? Thanks guys
That would be in the AFTER UPDATE event of the combo box (make sure it goes in the VBA window and not in the event properties dialog). Let us know if you have any trouble getting it there.
 
Sorry SOS, So I have the Combo box in my form. How can I access from there? I'm still new to Access. Thanks for the help.
 
Sorry SOS, So I have the Combo box in my form. How can I access from there? I'm still new to Access. Thanks for the help.

1. Open the form in design view.

2. Select the combo box.

3. Go find the properties dialog and then click on the EVENTS tab.

4. Find the AFTER UPDATE event and click in it.

5. A dropdown should appear and you select the item which reads [EVENT PROCEDURE].

6. An ellipsis (...) should appear at the right side of the area where [Event Procedure] now lies. Click on it.

7. That opens the VBA window where you will put your code.
 
Awesome! Thanks. :) But now Access freezes when I try to open the (...) I'll get it!
 
just type:

me.secondcolumn.setfocus
me.name.enabled = false
me.name.locked = true

-cacing

Hi! I know this thread has been around for quite some time now, but I've just come across it whilst looking for a solution to a similar problem (preventing a user changing a combo box selection after the initial selection).

The code cacing posted works great BUT - I need the combo box to be available/unlocked again when a new record is added to the form. Using the code as described above, the only way I can unlock the combo box seems to be to close / reopen the form which is not ideal.

Any ideas?

Many thanks
 
In the form's On Current event put it like this:

Me.ComboNameHere.Enabled = (Me.NewRecord)
Me.ComboNameHere.Locked = (Not Me.NewRecord)
 
In the form's On Current event put it like this:

Me.ComboNameHere.Enabled = (Me.NewRecord)
Me.ComboNameHere.Locked = (Not Me.NewRecord)

Thanks Bob, I think I must have misunderstood though as it doesn't seem to do anything, i.e combo is still locked even when new record is selected.

I've left the coding in the after update field of the combo box which locks it, and then put your coding in the forms on current event?

Thanks again
 
What is the exact code you used? Is this on a subform?
 
I don't think you ever need to Lock and Not Enable a control. If a control is disabled it doesn't matter if it's locked, and if you always unlock the control when you enable it then the lock doesn't matter again.
 
I don't think you ever need to Lock and Not Enable a control. If a control is disabled it doesn't matter if it's locked, and if you always unlock the control when you enable it then the lock doesn't matter again.

It is a visual and disallows selecting the text. If you lock a control you can select the text and copy it and if you lock and disable you can't select any of the text.

So it is programmer choice as to how they approach it. If you want your users to be able to click inside the control and select the text to copy, then don't disable too. If you don't, then disable too.
 
Bob, the code you posted never leaves the control in a Locked and Enabled state. In your code the control is either ...
1) Locked and Not Enabled
2) Not Locked and Enabled
In neither of those cases does the fact that the control is locked or not locked make any difference. If that is your intention then you don't need to lock or unlock the control. By contrast, if you want the control to be Locked and Enabled at some time then you need to change your logic.
Cheers,
 
Bob, the code you posted never leaves the control in a Locked and Enabled state. In your code the control is either ...
1) Locked and Not Enabled
2) Not Locked and Enabled
That is what it is SUPPOSED to do. That IS my intent. Did I not explain it properly?

Locked and Not Enabled keeps it from being able to be selected at all but it isn't grayed out.

Locked and Enabled lets the user select the text and copy it but they can't change it. I said that but apparently you didn't read it that way.
 
There are advantages to interchangeably setting the states of those two control properties as Bob has outlined. I'm sure you're aware of these.
 

Users who are viewing this thread

Back
Top Bottom