On Exit Function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What code do I need to use so that, say I have a combo box on a form that list store numbers. Say when they exit the combo box(such as tabbing to the next field or clicking on another field) I want to raise an error sort of like when the Item is not on the list and it forces the user to change the value to something that is in the list. I want to code something that will force the user to change the store number if it is the same as another field where I have the shipper. So if they first type in the shipper as 777 then they go to the store number field and select 777 and try to exit the field it will prompt them with a message such as "Must be different than shipper" and it keeps them in that combo box until they change the value to something else. Can anyone help. Thanks in advance.
 
One easy way to do this without a bunch of code is to simply use the
validation rule for the box. Let's say you have a field called "STORE" and
a field called "SHIPPER".

In the validation rule of "STORE" simply enter:

Not Like [shipper]

You can enter validation text similar to:

Store must not equal shipper. Make another selection.


Rick
Daniel Brown said:
What code do I need to use so that, say I have a combo box on a form that
list store numbers. Say when they exit the combo box(such as tabbing to the
next field or clicking on another field) I want to raise an error sort of
like when the Item is not on the list and it forces the user to change the
value to something that is in the list. I want to code something that will
force the user to change the store number if it is the same as another field
where I have the shipper. So if they first type in the shipper as 777 then
they go to the store number field and select 777 and try to exit the field
it will prompt them with a message such as "Must be different than shipper"
and it keeps them in that combo box until they change the value to something
else. Can anyone help. Thanks in advance.
 
Here's the deal Rick
Shipper for example has 0221 and Store Number is listed as 00221. They are the same but Store Number has the extra zero infront. How can I deal with this situation? Thanks for the help

----- Rick wrote: ----

One easy way to do this without a bunch of code is to simply use th
validation rule for the box. Let's say you have a field called "STORE" an
a field called "SHIPPER"

In the validation rule of "STORE" simply enter

Not Like [shipper

You can enter validation text similar to

Store must not equal shipper. Make another selection


Ric
Daniel Brown said:
What code do I need to use so that, say I have a combo box on a form tha
list store numbers. Say when they exit the combo box(such as tabbing to th
next field or clicking on another field) I want to raise an error sort o
like when the Item is not on the list and it forces the user to change th
value to something that is in the list. I want to code something that wil
force the user to change the store number if it is the same as another fiel
where I have the shipper. So if they first type in the shipper as 777 the
they go to the store number field and select 777 and try to exit the fiel
it will prompt them with a message such as "Must be different than shipper
and it keeps them in that combo box until they change the value to somethin
else. Can anyone help. Thanks in advance
 
Try:
<> [shipper]

That should work, provide both Shipper and Store Number are Text type
fields.

Reserve the Like operator for cases where you need to use wildcards.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Daniel Brown said:
Here's the deal Rick.
Shipper for example has 0221 and Store Number is listed as 00221. They
are the same but Store Number has the extra zero infront. How can I deal
with this situation? Thanks for the help.
----- Rick wrote: -----

One easy way to do this without a bunch of code is to simply use the
validation rule for the box. Let's say you have a field called "STORE" and
a field called "SHIPPER".

In the validation rule of "STORE" simply enter:

Not Like [shipper]

You can enter validation text similar to:

Store must not equal shipper. Make another selection.


Rick
Daniel Brown said:
What code do I need to use so that, say I have a combo box on a
form that
list store numbers. Say when they exit the combo box(such as tabbing to the
next field or clicking on another field) I want to raise an error sort of
like when the Item is not on the list and it forces the user to change the
value to something that is in the list. I want to code something that will
force the user to change the store number if it is the same as another field
where I have the shipper. So if they first type in the shipper as 777 then
they go to the store number field and select 777 and try to exit the field
it will prompt them with a message such as "Must be different than shipper"
and it keeps them in that combo box until they change the value to something
else. Can anyone help. Thanks in advance.
 
Back
Top