if statment problem

  • Thread starter Thread starter Agnes
  • Start date Start date
A

Agnes

Simple question: If Me.strPosttype ="ACCT" or Me.cboDocType.Text.Trim ="M"
, It should ignore the checking point .However, I found that I can do it.

If (Me.cboDocType.Text.Trim) <> "M" Or Me.strPostType <> "ACCT") Then
.........checkingpoint
end if

Now, I change my syntax into the following, the problem is solved. but
anyother simple way to do that.
If (Me.cboDocType.Text.Trim) <> "M" then
IF Me.strPostType <> "ACCT") Then
.........checkingpoint
end if
end if
 
Hi,

You should use and instead of or because you want both conditions to
be true.

If (Me.cboDocType.Text.Trim) <> "M" And Me.strPostType <> "ACCT") Then


Ken
-----------------------------
Simple question: If Me.strPosttype ="ACCT" or Me.cboDocType.Text.Trim ="M"
, It should ignore the checking point .However, I found that I can do it.

If (Me.cboDocType.Text.Trim) <> "M" Or Me.strPostType <> "ACCT") Then
.........checkingpoint
end if

Now, I change my syntax into the following, the problem is solved. but
anyother simple way to do that.
If (Me.cboDocType.Text.Trim) <> "M" then
IF Me.strPostType <> "ACCT") Then
.........checkingpoint
end if
end if
 
Agnes,
If (Me.cboDocType.Text.Trim) <> "M" then
IF Me.strPostType <> "ACCT") Then
.........checkingpoint
end if
end if

The syntax above is
If Me.cboDocType.Text.Trim <> "M" AndAlso Me.strPostType <> "ACCT" Then

Not Or

I hope this helps,

Cor
 
Agnes said:
Simple question: If Me.strPosttype ="ACCT" or Me.cboDocType.Text.Trim
="M" , It should ignore the checking point .However, I found that I can do
it.

NOT(A OR B) <-> NOT(A) AND NOT(B)

<-> ... logically equivalent.

=>

\\\
If Me.strPosttype <> "ACCT" AndAlso Me.cboDocType.Text.Trim() <> "M" Then
...
End If
///
 
Agnes said:
Simple question: If Me.strPosttype ="ACCT" or
Me.cboDocType.Text.Trim ="M" , it should ignore the
checking point.

How about this?

If Me.strPosttype = "ACCT" _
Or Me.cboDocType.Text.Trim = "M" _
Then
' Ignore the checking point
' Do Nothing - (my favourite comment)
Else
' checking point
End If

HTH,
Phill W.
 

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

Back
Top