Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Testing for Current Record

Status
Not open for further replies.

EddyLLC

Technical User
Mar 15, 2005
304
US
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?
 
You can disable the Delete button if the table has no records. Below are two different ways
Code:
Private Sub Form_Current()
    Me.cmdDelete.Enabled = DCount("*", "TableName") > 0
End Sub
Code:
Private Sub Form_Current()
    Me.cmdDelete.Enabled = Not Me.NewRecord
End Sub



________________________________________________________________________
Zameer Abdulla
Visit Me
No two children are alike - particularly if one is yours and the other isn't.
 
Hi

Or using the often neglected Recordsetclone property of a bound form

cmdDelete.Enabled = Me.RecordsetClone.RecordCount > 0



Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top