I am trying to generate an quote number using a query like:
stsql = "SELECT Max(Val(Mid([Quote],4))) AS [Number] From [Quote Numbers] GROUP BY Left([Quote],3) HAVING (((Left([Quote],3))='HTR'));"
The code that runs this is:
rstProject.Open stSQL, CurrentProject.Connection, adOpenForwardOnly
If .RecordCount = -1 Then
fnNewProjectNumber = 1
fnNewProjectNumber = !Number + 1
When I first ran it, I thought the RecordCount came back as -1 because there were no records, but now the query does return a record, but the RecordCount is still -1.
If an aggregate query always returns -1, how can you handle the case when there are no records?