count query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ineedahelp
    New Member
    • Sep 2006
    • 98

    count query

    I have some code that counts the number of times that 0 (zero) is entered in a table. I want to save this to a variable and print it out in a msgbox. What I get as the variable is a repeat of the select statement. what am I doing wrong? Here is my code

    Dim Zeros As Integer

    Zeros = "SELECT Count(MarketDat aTemp.ACPS) AS CountOfACPS" & _
    "FROM MarketDataTemp" & _
    "WHERE (((MarketDataTe mp.ACPS)=0));"
    Debug.Print Zeros
    MsgAnswer = MsgBox("There are " & Zeros & "prices equal to '0' in the MarketData file", vbYesNo)
    If MsgAnswer = 7 Then
    Exit Sub
    End If
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by ineedahelp
    I have some code that counts the number of times that 0 (zero) is entered in a table. I want to save this to a variable and print it out in a msgbox. What I get as the variable is a repeat of the select statement. what am I doing wrong? Here is my code

    Dim Zeros As Integer

    Zeros = "SELECT Count(MarketDat aTemp.ACPS) AS CountOfACPS" & _
    "FROM MarketDataTemp" & _
    "WHERE (((MarketDataTe mp.ACPS)=0));"
    Debug.Print Zeros
    MsgAnswer = MsgBox("There are " & Zeros & "prices equal to '0' in the MarketData file", vbYesNo)
    If MsgAnswer = 7 Then
    Exit Sub
    End If

    Dim intNoOfZeros As Integer
    intNoOfZeros = DCount("*", "MarketDataTemp ", "[MarketDataTemp].[ACPS]=0")
    'The rest is easy enough

    Comment

    • ineedahelp
      New Member
      • Sep 2006
      • 98

      #3
      Originally posted by ADezii
      Dim intNoOfZeros As Integer
      intNoOfZeros = DCount("*", "MarketDataTemp ", "[MarketDataTemp].[ACPS]=0")
      'The rest is easy enough
      It worked like a charm...thank you much!!

      Comment

      Working...