Data Mismatch in comparison

W

Wendy

I'm doing something stupid, but am too blind to see:

If Me.FP_PU_YEAR <> "L5" Or "F" then
Me.Frame56.visible = false
end if

I'm just trying to hide a frame control if a field value is not equal to the
condition.

FP_PU_YEAR returns U6 for example and I get a type mismatch error.

The field is set to TEXT in table design.

Cheers
 
S

Stefan Hoffmann

hi Wendy,
I'm doing something stupid, but am too blind to see:
If Me.FP_PU_YEAR <> "L5" Or "F" then
If (Me.FP_PU_YEAR <> "L5") Or (Me.FP_PU_YEAR <> "F") then


mfG
--> stefan <--
 
D

Douglas J Steele

Stefan Hoffmann said:
hi Wendy,


If (Me.FP_PU_YEAR <> "L5") Or (Me.FP_PU_YEAR <> "F") then

Actually, that won't work. No field can have two values, therefore that will
always be true (if the field contains L5, it can't contain F, and vice
versa, so at least one of the two comparisons is always going to be true)

While you may use OR in English to explain what you want, in Boolean logic,
you need to use AND:

If (Me.FP_PU_YEAR <> "L5") AND (Me.FP_PU_YEAR <> "F") then

You could also use:

If Not ((Me.FP_PU_YEAR = "L5") OR (Me.FP_PU_YEAR = "F")) then

or

If Me.FP_PU_YEAR NOT IN ("L5", "F") then
 

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