syntax error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • favor08
    New Member
    • Jan 2007
    • 56

    syntax error

    How can I tie the users shortname to this code. so it comes back with the results that only apply to them.

    Dim pastdue As Integer
    Dim current As Integer
    Dim tot As Integer

    nodate = DCount("*", "TARA", "isNull(penddte )")
    pastdue = DCount("*", "TARA", "penddte < date()")
    current = DCount("*", "TARA", "penddte >= date()")
    tot = DCount("*", "TARA")

    Debug.Print nodate, pastdue, current, tot
    Me.message = "You have " & tot & " items with " & pastdue & " past due, " & current & " current and " & nodate & " with no pending date"


    End Sub


    Right now it totals the entire database. I have a text box called txtusername that captures the users shortname when they login (using a function) that same shortname is in the maintable and that field is called Login id.

    So what I would want to say is: count the number of items where the "penddte"(anoth er field in the maintable) isnull and the txtusername is = to the field called loginid. I don't think I have my syntax correct. i get an cancell operation error.
    nodate = DCount("*", "TARA", "isNull(penddte )" & " and [loginID]= " & Me.txtUserName)
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    Try this ...
    Code:
    nodate = DCount("*", "TARA", "[penddte] Is Null" & " and [loginID]= '" & Me.txtUserName & "'")
    Mary

    Comment

    • favor08
      New Member
      • Jan 2007
      • 56

      #3
      Originally posted by mmccarthy
      Try this ...
      Code:
      nodate = DCount("*", "TARA", "[penddte] Is Null" & " and [loginID]= '" & Me.txtUserName & "'")
      Mary

      thank you, It work on all lines but the last one:

      Code:
      tot = DCount("*", "TARA" & " and [loginID]= '" & Me.txtUserName & "'")
      Last edited by NeoPa; Mar 23 '07, 01:02 AM. Reason: Tags

      Comment

      • MMcCarthy
        Recognized Expert MVP
        • Aug 2006
        • 14387

        #4
        Try this ...

        Code:
         tot = DCount("*", "TARA" & "[loginID]= '" & Me.txtUserName & "'")

        Comment

        • favor08
          New Member
          • Jan 2007
          • 56

          #5
          Originally posted by mmccarthy
          Try this ...

          Code:
           tot = DCount("*", "TARA" & "[loginID]= '" & Me.txtUserName & "'")

          I get an error that says the microsoft engine can not find the input table or query "tara[loginid]="myshortnam e" make sure it exit and it is spelled correcty.

          which both are.

          Comment

          • MMcCarthy
            Recognized Expert MVP
            • Aug 2006
            • 14387

            #6
            Originally posted by favor08
            I get an error that says the microsoft engine can not find the input table or query "tara[loginid]="myshortnam e" make sure it exit and it is spelled correcty.

            which both are.
            Sorry my fault for not checking the syntax.

            Code:
            tot = DCount("*", "TARA", "[loginID]= '" & Me.txtUserName & "'")

            Comment

            • favor08
              New Member
              • Jan 2007
              • 56

              #7
              Originally posted by mmccarthy
              Sorry my fault for not checking the syntax.

              Code:
              tot = DCount("*", "TARA", "[loginID]= '" & Me.txtUserName & "'")

              Thank you so much. This works!!

              Comment

              • MMcCarthy
                Recognized Expert MVP
                • Aug 2006
                • 14387

                #8
                You're welcome.

                Comment

                Working...