By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,990 Members | 1,990 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,990 IT Pros & Developers. It's quick & easy.

if statment problem

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
-----------------------------
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

Nov 21 '05 #2

P: n/a
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
Nov 21 '05 #3

P: n/a
"Agnes" <ag***@dynamictech.com.hk> schrieb:
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
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

P: n/a
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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.
Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.