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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting records in a DB

Status
Not open for further replies.

allis

Technical User
Oct 16, 2002
11
US
On my delete button, I have a message box come up asking if they are sure they want to delete, yes or no, and the according action is taken.

My problem is that when the database is empty, I have another message box come up saying that the database is empty and that there are no records. The problem is, the message box asking whether they are sure they want to delete still comes up, and should not come up in the instance that the database is empty.

Also, when the record deletes, and is at EOF, it is set to move previous, well if it is empty, it can not move to the previous record and results in an error message, how do I fix this?

Thank you
 
Before you ask the user if they want to delete the record, find out if the table is empty. Or Disable the DELETE button until there are records in the table. Maybe on the form load or where ever check for .bof and .eof

if this check comes back true, then disable the Delete button. Otherwise, Enable it.

ie.

rs.open "Select count(*) from TableName",Connection, openoptions,etc...

if rs.recordcount = 0 then
cmdDelete.disabled = true
else
cmdDelete.enabled = true
End If

That way you know immediately if you can even click the DELETE button.

Good Luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top