Record Existing checks

roland_access

Registered User.
Local time
Today, 10:31
Joined
Feb 13, 2002
Messages
35
Ive set up a timer on a form that needs to display a message box if ANY records are present in a table. Normally the table is empty, but if one record is present i need the message box to appear. How would I do this? Treat me as a bit of a novice please.
 
In the timer event, set up a recordset based on the table and check it's RecordCount property.


Dim rst As recordset
dim dbs as database
dim strSql as string

Set dbs = currentdb
strSql = "SELECT * FROM tblWhatever;"
set rst = dbs.openrecordset (strSql, dbopensnapshot)

If rst.recordcount > 0 then
msg "Message"
end if

'Make sure to close your object variables!

Exit:
set rst = nothing
set dbs = nothing
exit sub

HTH
Chris
 

Users who are viewing this thread

Back
Top Bottom