If Statement

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

I am wanting to have the following if statement if the following DB_Wood or
DB_Plastic check boxes are not checked. It will display the following message.


I get an error #13 Type Mismatch.

What am I doing wrong?

If DB_Wood Or DB_Plastic = False Then
MsgBox "You need to select the flooring material. " & _
vbOKOnly, "Select Material"
End If
 
J

Jeanette Cunningham

Hi matt,

Use If DB_Wood = False Or DB_Plastic = False Then

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
M

mattc66 via AccessMonster.com

It doesn't seem to be picking up the OR. If both are checked it passed by the
if. If one or the other are selected the message appears. The message is only
supposed to appear if nothing is checked.

Jeanette said:
Hi matt,

Use If DB_Wood = False Or DB_Plastic = False Then

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
I am wanting to have the following if statement if the following DB_Wood or
DB_Plastic check boxes are not checked. It will display the following
[quoted text clipped - 8 lines]
vbOKOnly, "Select Material"
End If
 
J

Jeanette Cunningham

mattc66 via AccessMonster.com said:
It doesn't seem to be picking up the OR. If both are checked it passed by
the
if. If one or the other are selected the message appears. The message is
only
supposed to appear if nothing is checked.

Jeanette said:
Hi matt,

Use If DB_Wood = False Or DB_Plastic = False Then

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
I am wanting to have the following if statement if the following DB_Wood
or
DB_Plastic check boxes are not checked. It will display the following
[quoted text clipped - 8 lines]
vbOKOnly, "Select Material"
End If
 
J

Jeanette Cunningham

Use 'And' instead of 'Or'

If DB_Wood = False And DB_Plastic = False Then


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


mattc66 via AccessMonster.com said:
It doesn't seem to be picking up the OR. If both are checked it passed by
the
if. If one or the other are selected the message appears. The message is
only
supposed to appear if nothing is checked.

Jeanette said:
Hi matt,

Use If DB_Wood = False Or DB_Plastic = False Then

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
I am wanting to have the following if statement if the following DB_Wood
or
DB_Plastic check boxes are not checked. It will display the following
[quoted text clipped - 8 lines]
vbOKOnly, "Select Material"
End If
 
M

mattc66 via AccessMonster.com

However if one or the other is checked then I don't want the message to
appear. Would that mean both would have to be not checked to get the message?

Jeanette said:
Use 'And' instead of 'Or'

If DB_Wood = False And DB_Plastic = False Then

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
It doesn't seem to be picking up the OR. If both are checked it passed by
the
[quoted text clipped - 14 lines]
 
J

Jeanette Cunningham

Yes, using 'And' means that the message will only show if both things are
false.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


mattc66 via AccessMonster.com said:
However if one or the other is checked then I don't want the message to
appear. Would that mean both would have to be not checked to get the
message?

Jeanette said:
Use 'And' instead of 'Or'

If DB_Wood = False And DB_Plastic = False Then

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
It doesn't seem to be picking up the OR. If both are checked it passed
by
the
[quoted text clipped - 14 lines]
vbOKOnly, "Select Material"
End If
 
M

Mike Painter

Jeanette answered your questions but I want to add a bit more about "OR"

a OR b means (in programming) that either or both can be true. It is not the
same as the "or" used in "chocolate or vanilla"
That is an exclusive "OR", usually written "XOR"
 

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