D
Denis Bisson via AccessMonster.com
Good day,
A2K on a Win2K platform
My objective is to have a pop-up form appear when the database opens, ONLY
if there are one or more records that result from an SQL statement. At the
moment, I am substituting the pop-up form with MsgBoxes – only for testing
purposes.
The function below is called from an “AutoExec” macro and partially works…
The IF RecordCount only returns a value of “1” even though the number of
records should be higher (for testing purposes I should see “3” records
instead of only one.
What am I missing?
Thank you
Denis
Public Function LinkChk()
Dim dbs As DAO.Database, rst As DAO.Recordset
Dim strSQL As String
Set dbs = CurrentDb
strSQL = "SELECT Register.ID, Register.QDCN, Register.[Title of document]
, " _
& "Register.TentativeAuditDate, Register.LinksCheckedDate " _
& "FROM Register " _
& "WHERE (((Register.TentativeAuditDate)<Now() OR
(Register.TentativeAuditDate)<Now()+ 300) AND ((Register.LinksCheckedDate)
Is Null));"
Set rst = dbs.OpenRecordset(strSQL)
If rst.RecordCount > 0 Then
MsgBox "There is/are " & rst.RecordCount & " product(s) scheduled for
an audit requiring links to be checked"
Else
MsgBox "No products requiring link check"
End If
Debug.Print rst.RecordCount
Set dbs = Nothing
End Function
A2K on a Win2K platform
My objective is to have a pop-up form appear when the database opens, ONLY
if there are one or more records that result from an SQL statement. At the
moment, I am substituting the pop-up form with MsgBoxes – only for testing
purposes.
The function below is called from an “AutoExec” macro and partially works…
The IF RecordCount only returns a value of “1” even though the number of
records should be higher (for testing purposes I should see “3” records
instead of only one.
What am I missing?
Thank you
Denis
Public Function LinkChk()
Dim dbs As DAO.Database, rst As DAO.Recordset
Dim strSQL As String
Set dbs = CurrentDb
strSQL = "SELECT Register.ID, Register.QDCN, Register.[Title of document]
, " _
& "Register.TentativeAuditDate, Register.LinksCheckedDate " _
& "FROM Register " _
& "WHERE (((Register.TentativeAuditDate)<Now() OR
(Register.TentativeAuditDate)<Now()+ 300) AND ((Register.LinksCheckedDate)
Is Null));"
Set rst = dbs.OpenRecordset(strSQL)
If rst.RecordCount > 0 Then
MsgBox "There is/are " & rst.RecordCount & " product(s) scheduled for
an audit requiring links to be checked"
Else
MsgBox "No products requiring link check"
End If
Debug.Print rst.RecordCount
Set dbs = Nothing
End Function