if statment problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Agnes

    #1

    if statment problem

    Simple question: If Me.strPosttype ="ACCT" or Me.cboDocType.T ext.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
    .........checki ngpoint
    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
    .........checki ngpoint
    end if
    end if


  • Ken Tucker [MVP]

    #2
    Re: if statment problem

    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" <agnes@dynamict ech.com.hk> wrote in message
    news:%23mG1S01Z FHA.1044@TK2MSF TNGP10.phx.gbl. ..
    Simple question: If Me.strPosttype ="ACCT" or Me.cboDocType.T ext.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
    .........checki ngpoint
    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
    .........checki ngpoint
    end if
    end if



    Comment

    • Cor Ligthert

      #3
      Re: if statment problem

      Agnes,
      [color=blue]
      > If (Me.cboDocType. Text.Trim) <> "M" then
      > IF Me.strPostType <> "ACCT") Then
      > .........checki ngpoint
      > end if
      > end if[/color]

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

      Not Or

      I hope this helps,

      Cor


      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: if statment problem

        "Agnes" <agnes@dynamict ech.com.hk> schrieb:[color=blue]
        > Simple question: If Me.strPosttype ="ACCT" or Me.cboDocType.T ext.Trim
        > ="M" , It should ignore the checking point .However, I found that I can do
        > it.[/color]

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

        <-> ... logically equivalent.

        =>

        \\\
        If Me.strPosttype <> "ACCT" AndAlso Me.cboDocType.T ext.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/>

        Comment

        • Phill.  W

          #5
          Re: if statment problem

          "Agnes" <agnes@dynamict ech.com.hk> wrote in message
          news:%23mG1S01Z FHA.1044@TK2MSF TNGP10.phx.gbl. ..[color=blue]
          > Simple question: If Me.strPosttype ="ACCT" or
          > Me.cboDocType.T ext.Trim ="M" , it should ignore the
          > checking point.[/color]

          How about this?

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

          HTH,
          Phill W.


          Comment

          Working...