ignoring change in combo box

A

alekm

Hi,
how can I completly ignore change in combo box if some terms are not
fulfilled, ei if someone picks something in combo box I want to check if some
terms are fulfilled and judging on that I shall allow change on combo box or
not. If terms are not fulfilled I want combo box to stay with old value, just
as nothing has happend.

thanx in advance

alek_mil
 
K

Keith Wilby

alekm said:
Hi,
how can I completly ignore change in combo box if some terms are not
fulfilled, ei if someone picks something in combo box I want to check if
some
terms are fulfilled and judging on that I shall allow change on combo box
or
not. If terms are not fulfilled I want combo box to stay with old value,
just
as nothing has happend.

thanx in advance

alek_mil

You *could* put some validation code in the form's Before Update event but I
can see that being problematic, particularly when your user scratches their
head and can't understand why the change they made has not been saved. It
might be better to have your code lock the combo box until the other
conditions have been met or to have it raise an error message telling the
user why they can't make the change.

Could you not calculate the value in a query?

Keith.
www.keithwilby.co.uk
 
A

alekm

I can raise an error message, but I also want to automatically get back to
old value and not to depend on the user.
I guess the Before Update event is to be used but I still can't see the way
to ignore 'wrong choice' completly.

thanx

alek_mil
 
K

Keith Wilby

alekm said:
I can raise an error message, but I also want to automatically get back to
old value and not to depend on the user.
I guess the Before Update event is to be used but I still can't see the
way
to ignore 'wrong choice' completly.

You could have something like this in your form's before update event:

If Me.chkMyCheckBox =True Or Me.txtMyTextBox = "whatever" Or
Me.orgMyOptionGroup = 1 Then
MsgBox "Cannot choose this value unless whatever."
Cancel = True
End If

That won't reinstate the old value but it won't allow the record to be saved
unless your conditions are met. The user would press Esc to leave the
record unchanged, although you could also use Me.Undo in your code.

HTH - Keith.
www.keithwilby.co.uk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top