Testing for Last Record

  • Thread starter Thread starter Gibson
  • Start date Start date
G

Gibson

Is there a way to test if there is a current record of if the table is
empty? I am using the following code behind an OnClick event to delete a
record in a table.

If Not Me.NewRecord Then
intResponse = MsgBox("Are you sure you want to delete Line?",
vbQuestion + vbYesNo, "Delete Line")
If intResponse = vbYes Then
RunCommand acCmdDeleteRecord
RunCommand acCmdRecordsGoToLast
End If
End If

After I delete the record I would like to test to see if I just deleted the
last record in the table and if so do something. Is there way to test to
see if no more records exist in the table?
 
There are no records in a form if:
(Me.CurrentRecord = 1) And (Me.NewRecord)
An alternative approach:
Me.RecordsetClone.RecordCount = 0

However, that could be because it is filtered, or in data entry mode.
There are no records in the table if DLookup() on the primary key of the
table produces null, e.g.:
IsNull(DLookup("ID", "Table1"))
 
Back
Top