L
Lee Roper
I have a table called Data. The key identifying field in
the table is called Claimno (claim number). I want my
users to be able to click a button on a form and get a
count of the number of unique claim numbers in the data
table. To do this, I have tried to build a SQL statement
that will select the Claimno field and GROUP BY that
field. I assume that I will have to do a separate SQL
statement to count the grouped claim numbers. If there is
an easier way to do this, I'd appreciate the info.
I was informed that I would need to create a stored query
so I searched Help on how to create a querydef. Based on
this, I created the following code:
Dim dbsRepricer as DAO.Database
Set dbsRepricer = CurrentDb
Dim rsClaims As DAO.Recordset
Dim qdfClaimno As QueryDef
With dbsRepricer
Set qdfClaimno = .CreateQueryDef("SELECT claimno
FROM Data GROUP BY claimno")
Set rsClaims = .OpenRecordset(qdfClaimno,
dbOpenTable)
End With
It keeps giving me a Type Mismatch error and highlights
the line for OpenRecordset. What am I doing wrong?
Thanks, Lee
the table is called Claimno (claim number). I want my
users to be able to click a button on a form and get a
count of the number of unique claim numbers in the data
table. To do this, I have tried to build a SQL statement
that will select the Claimno field and GROUP BY that
field. I assume that I will have to do a separate SQL
statement to count the grouped claim numbers. If there is
an easier way to do this, I'd appreciate the info.
I was informed that I would need to create a stored query
so I searched Help on how to create a querydef. Based on
this, I created the following code:
Dim dbsRepricer as DAO.Database
Set dbsRepricer = CurrentDb
Dim rsClaims As DAO.Recordset
Dim qdfClaimno As QueryDef
With dbsRepricer
Set qdfClaimno = .CreateQueryDef("SELECT claimno
FROM Data GROUP BY claimno")
Set rsClaims = .OpenRecordset(qdfClaimno,
dbOpenTable)
End With
It keeps giving me a Type Mismatch error and highlights
the line for OpenRecordset. What am I doing wrong?
Thanks, Lee