Limiting Combo Box Entry Based On Another Field

G

Guest

Let's say I have two items on a form, a combo box with a pre-established list
of items to choose from (named "Title"), and another combo box with a list of
integers and a blank (" ") as selections (named "Survey"). If "Survey" is
blank, the user can enter any text he wants into "Title". If the user
selects anything other than a blank from the "Survey" combo box, I set
LimitToList to "Yes" (in VBA) for "Title" so that the user must then select
one of the pre-established items. The only problem is, when the user leaves
the current record (or just saves the changes), I am not seeing the error
message that tells the user to select from the list. The record is accepted
no matter what text is in "Title".

How can I force the user to select from the list in "Title" when he chooses
an integer from "Survey"? Just turning on LimitToList didn't do it.

Thanks,

Eric
 
G

Guest

Use the form's BeforeUpdate event to validate the fields.

I usually create a validation function that returns True or False.

Then in the BeforeUpdate event:
If MyFunction = False Then
Cancel = True
End If

The user will not be able to save or move to another record until it passes
validation or current changes are cancelled (undone).

Steve
 
G

Guest

Thanks, that works very well! I put up a warning message, then I drop down
the combo list so the user understands that he must make a selection. Very
visual, and probably somewhat annoying.
 

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

Top