Checking for zero records (1 Viewer)

Gismo

Registered User.
Local time
Today, 13:10
Joined
Jun 12, 2017
Messages
1,298
Hi All,

I am checking for zero records in a table
If zero, then I need to run a append query
I am now getting duplicate records which tells me the code might not be checking for zero records
There is no duplicate in the append query
So I recon the table was not blank to start off with and now being duplicated

Private Sub Form_Load()
If Me.RecordsetClone.RecordCount = 0 Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "Update_Registration_All"
Forms![StatusRegFilter]![DAWSheetStatus].Form.Requery
DoCmd.SetWarnings True
End If

End Sub
 

CJ_London

Super Moderator
Staff member
Local time
Today, 11:10
Joined
Feb 19, 2013
Messages
16,607
you have to movelast before you will get a recordcount other than 0

perhaps use EOF instead?

If Me.RecordsetClone.EOF Then

As an aside, advise you inset your code for easier reading and debugging
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:10
Joined
May 7, 2009
Messages
19,234
you can also use DCount() to check if there is record:

If DCount("1", "yourTable") = 0 Then
 

Users who are viewing this thread

Top Bottom