Dcount woes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • leeg
    New Member
    • Dec 2006
    • 14

    #1

    Dcount woes

    Afternoon,

    new to here and new to programming. Well I'm not, I'm just not good at it!!

    I am trying to count the number of records with a priority of "high" that also has a blank completed date. I assume it's possible?

    My syntax (that's not working) is -

    intStore = DCount("[Job Reference no]", "mainjobfor m", "[Priority rating]= 'high'" And "[Date completed] = ''")

    Please can someone help before I throw myself out of the window!!!

    Thanks in anticipation. Graeme
  • leeg
    New Member
    • Dec 2006
    • 14

    #2
    Originally posted by leeg
    Afternoon,

    new to here and new to programming. Well I'm not, I'm just not good at it!!

    I am trying to count the number of records with a priority of "high" that also has a blank completed date. I assume it's possible?

    My syntax (that's not working) is -

    intStore = DCount("[Job Reference no]", "mainjobfor m", "[Priority rating]= 'high'" And "[Date completed] = ''")

    Please can someone help before I throw myself out of the window!!!

    Thanks in anticipation. Graeme
    Sorry, here is all my code for this

    Code:
    Private Sub Form_Load()
    
    'On Load of the switchboard check Jobs table for any incomplete jobs
    
    Dim intStore As Integer
    
    'Count of incomplete jobs that are high priority and incomplete
    intStore = DCount("[Job Reference no]", "mainjobform", "[Priority rating]= 'high'" And "[Date completed] = ''")
    'If count of incomplete jobs is zero display switchboard
    'Else display message box detailing amount of jobs
    'and give the user the option as to whether to view these or not.
        If intStore = 0 Then
                Exit Sub
                    Else
                        If MsgBox("There are " & intStore & " incomplete High priority jobs" & _
                        vbCrLf & vbCrLf & "Would you like to see these now?", _
                        vbYesNo, "You have incomplete high priority jobs...") = vbYes Then
                        DoCmd.Close
                        DoCmd.OpenForm "FormOutstandingHighJobs", acNormal
                    Else
                Exit Sub
            End If
        End If
    End Sub


    Thanks

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      Code:
      intStore = DCount("[Job Reference no]", _
                        "TableorQueryName", _
                        "((LCase([Priority rating])='high') " & _
                        "And (Nz([Date completed],'')=''))")
      This is a start but without the Table MetaData I don't know for sure how the check for 'High should be done.
      Originally posted by NeoPa
      Here is an example of how to post table MetaData :
      Posting Table/Dataset MetaData
      Code:
      [b]Table Name=tblStudent[/b]
      StudentID; Autonumber; PK
      Family; String; FK
      Name; String
      University; String; FK
      MaxMark; Numeric
      MinMark; Numeric

      Comment

      • MMcCarthy
        Recognized Expert MVP
        • Aug 2006
        • 14387

        #4
        Originally posted by leeg
        Afternoon,

        new to here and new to programming. Well I'm not, I'm just not good at it!!

        I am trying to count the number of records with a priority of "high" that also has a blank completed date. I assume it's possible?

        My syntax (that's not working) is -

        intStore = DCount("[Job Reference no]", "mainjobfor m", "[Priority rating]= 'high'" And "[Date completed] = ''")

        Please can someone help before I throw myself out of the window!!!

        Thanks in anticipation. Graeme
        You can't run DCount against the form. You have to run it on the table or query on which the form is based. You also have too many quotes which I have removed.

        Mary

        Code:
         
        intStore = DCount("[Job Reference no]", "table/query name", "[Priority rating]= 'high' And [Date completed] Is Null")

        Comment

        • leeg
          New Member
          • Dec 2006
          • 14

          #5
          Mary, I love you!!!! And thanks to Neopa

          I tried every permutation of syntax that I could think of. Greatly appreciate your time and skills. Thankyou.

          I wasn't trying to dcount against a form. The table name is actually mainjobform :o) Can you tell I'm not a programmer!!!!

          Regards, Graeme

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32669

            #6
            Originally posted by leeg
            Mary, I love you!!!! And thanks to Neopa

            I tried every permutation of syntax that I could think of. Greatly appreciate your time and skills. Thankyou.

            I wasn't trying to dcount against a form. The table name is actually mainjobform :o) Can you tell I'm not a programmer!!!!

            Regards, Graeme
            Lol Graeme.

            In answer to your question - No.
            I'm afraid that that sort of thing is quite common even among programmers.
            Very few understand that conventions and consistency are elements that they, as programmers, will benefit from greatly :(.

            Comment

            • MMcCarthy
              Recognized Expert MVP
              • Aug 2006
              • 14387

              #7
              Originally posted by leeg
              Mary, I love you!!!! And thanks to Neopa

              I tried every permutation of syntax that I could think of. Greatly appreciate your time and skills. Thankyou.

              I wasn't trying to dcount against a form. The table name is actually mainjobform :o) Can you tell I'm not a programmer!!!!

              Regards, Graeme
              You're welcome Graeme.

              Mary

              Comment

              Working...