Count the number of rows in a query result
Solved
angelo2night
-
DALAF -
DALAF -
Hello,
I am trying to code in VBA under Access 2007 a macro that would allow me to count the number of rows in a query result.
I have a table where I extract the desired information through a query and display it.
What I can't do is create a MsgBox that shows me the number of rows.
RecapChantierEffectue: this is the name of my query that allows me to display the desired information.
Here is my code that executes upon a click:
Private Sub Commande0_Click()
Dim cpt As Integer
'Execution of the query
'DoCmd.OpenQuery "Queryname",acReadOnly to allow the user to view only
DoCmd.OpenQuery "RecapChantierEffectue", acReadOnly
cpt = DCount("*&, "RecapChantierEffectue")
MsgBox ("you have completed a total of " &cpt " construction sites")
End Sub
The DCount does not work! Please help me!
Configuration: Windows Vista / Firefox 8.0
I am trying to code in VBA under Access 2007 a macro that would allow me to count the number of rows in a query result.
I have a table where I extract the desired information through a query and display it.
What I can't do is create a MsgBox that shows me the number of rows.
RecapChantierEffectue: this is the name of my query that allows me to display the desired information.
Here is my code that executes upon a click:
Private Sub Commande0_Click()
Dim cpt As Integer
'Execution of the query
'DoCmd.OpenQuery "Queryname",acReadOnly to allow the user to view only
DoCmd.OpenQuery "RecapChantierEffectue", acReadOnly
cpt = DCount("*&, "RecapChantierEffectue")
MsgBox ("you have completed a total of " &cpt " construction sites")
End Sub
The DCount does not work! Please help me!
Configuration: Windows Vista / Firefox 8.0