Exact Validation Rules for a combo boxes

P

PJ

Hi All,
I want to validate to either alllow or deny a user's entry to certain combo
boxes in the form. The comboxes have the lists from another table. So this
is what I have in the BeforeUpdate

if cboPlace <> "Away" or cboPlace <> "Home" or cboPlace <> "Dont Know" then
me.undo
cboPlace.SetFocus
end if

but that's not working. Please help.

And other cbos are pulling from a table, which has a lot more data, how do i
go about validating that without having to hardcode it? Thanks.
 
P

PJ

I was able to use the validation rule for the tables, but i cant figure out
how to use the validation rule for the query.
 
P

PJ

Hi All,
I played around with the dlookup and came up with this:

Dim ValiRule as Variant
ValiRule = Nz(DLookup("Place","tblPlace"),0)

if cboPlace.value <> Valirule then
msgbox "debug"
me.undo
end if

but with the code above, it pick up a certain row and stick with it. So no
matter what, i cant change it, please help. thanks
 
J

John W. Vinson

Hi All,
I want to validate to either alllow or deny a user's entry to certain combo
boxes in the form. The comboxes have the lists from another table. So this
is what I have in the BeforeUpdate

if cboPlace <> "Away" or cboPlace <> "Home" or cboPlace <> "Dont Know" then
me.undo
cboPlace.SetFocus
end if

but that's not working. Please help.

And other cbos are pulling from a table, which has a lot more data, how do i
go about validating that without having to hardcode it? Thanks.

I have no idea whatsoever what would be valid and what would be invalid. Your
not-equals expression certainly will not work; If cboPlace = "Away" then it is
not equal to "Home", so the IF statement will ALWAYS be true, for any value of
cboPlace.

Could you explain a) what you are trying to accomplish, in words, and b) where
you intend to put this code? Are you just trying to limit cboPlace to those
three values? If so, simply set its Limit to List property to true and its
Rowsource to a query or table with those values.


John W. Vinson [MVP]
 

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