Data Mismatch in comparison

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

Guest

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
 
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 <--
 
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
 
Back
Top