Lock the combobox after update

perkar

New member
Local time
Tomorrow, 00:59
Joined
Jun 3, 2013
Messages
3
Hey.
The company's register of projects we select the customer from a combo box that is related to the customer table. However, the way this works now, the individual may choose another customer by mistake, and if this is not corrected at the time the project will be listed with the wrong customer.
I would like to have a feature that when you select a customer receive a message if you are sure this is the right customer and if you answer yes then the customers name is being locked to this project ID.

Anyone have an idea of how to do this?
 
Perhaps some code in the Before Update event of the combo box which asks for confirmation of the users selection. If the confirmation is rejected, the update can be cancelled.
 
Hey.
The company's register of projects we select the customer from a combo box that is related to the customer table. However, the way this works now, the individual may choose another customer by mistake, and if this is not corrected at the time the project will be listed with the wrong customer.
I would like to have a feature that when you select a customer receive a message if you are sure this is the right customer and if you answer yes then the customers name is being locked to this project ID.

Anyone have an idea of how to do this?

You are working with two aims that seem at cross purposes. If the customer assigned to a project is incorrect, you can go to the project record and change it. If you lock the project to a certain customer, you are stuck with the choice. I would not place much trust in the "are you sure" message because at the moment the user may feel assured the customer selection is correct even though it isn't.

So I would recommend to leave the combobox enabled, just in case the assignment error is dicovered later.

Best,
Jiri
 
Thanks for answering this question and I'm agree that you should have the option to change the customer if its selected by a mistake but couldn't this option be possible by using a check box where the box has to be enabled if you like to change the name of the customer.
 
Thanks for answering this question and I'm agree that you should have the option to change the customer if its selected by a mistake but couldn't this option be possible by using a check box where the box has to be enabled if you like to change the name of the customer.

Consider doing the following:

sure - add a checkbox to your table and form. (note: unbound checkboxes won't work well)

---- pseudocode below - you may have to adjust it for it to actually work.
form on open:
if me.chkbox = true then me.customer.locked = True

checkbox on update:
if me.chkbox = true then me.customer.locked = True
if me.chkbox = false then me.customer.locked = False
me.refresh
 
Thanks for answering this question and I'm agree that you should have the option to change the customer if its selected by a mistake but couldn't this option be possible by using a check box where the box has to be enabled if you like to change the name of the customer.

It is possible but again I would caution against this. The simple reason is that you would want to lock the combobox always after you insert a record. In other words, if a record exists in the project table, you cannot change the customer in it. So there is no binary situation to track with another control on the form. So, ok put the checkbox on the form, keep it empty, until you need to change the record. Then you check it, change the customer selection, then you uncheck it again so you cannot change the record. So what does that give you ? What security is in that ? You change the record with the checkbox or you can change the record without it. See what I mean ?

There are situations when you would want protect certain fields from unauthorized changes. You can do that in the OnCurrent event by
by
Code:
If Me.NewRecord then 
    Me!MyField.Enabled = True
Ese
    Me!MyField.Enabled = False
End If

The problem with that is that you cannot search records via the Find button facility with that. So what I do instead is leave the field enabled but put the following statement in the BeforeUpdate event

Code:
If Not Me.NewRecord THEN
   Me!MyField = Me!MyField.OldValue
End If

As some of my programs have security built into them I allow logged_in users with supervisor's privileges to override the restriction, like

Code:
If glbUserLevel = "supervisor" Then 
    Exit Sub 
ELseIf Not Me.NewRecord THEN
   Me!MyField = Me!MyField.OldValue
End If

This is my generic approach to resticting access to fields with sensitive data. Good Luck !

Best,
Jiri
 

Users who are viewing this thread

Back
Top Bottom