Delete Problem

aziz rasul

Active member
Local time
Today, 18:31
Joined
Jun 26, 2000
Messages
1,935
I have a form based on a table. Included on the form is a check box and a command button.

The idea is when I want to delete a particular record, I place a tick in the check box and press the command button. The code behind the command button is: -

DoCmd.OpenQuery "qryDelete TRUST - Specific"
Me.Requery

The delete query reads the check box and deletes the record.

The problem is that if I press the command button once, the record still appears on the form and the table. If I press the command button a second time only then does the record disappear on the form and hence the table.

How do I ensure that if I only press the command button once, the record should not only delete BUT move onto the next record in the recordset on the form.

I managed to solve the problem by placing

Me.Requery

in the AfterUpdate event of the check box. However the problem I have then is that it takes me to the first record rather than to the next record. Hence the user has to trudge to the next record manually and continue from there.
 
Why not just delete the record with the cmd button?

Place the following code behind the 'click' event;

DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True

The next record should then be automatically displayed.
The 'setwarnings' stop access displaying a warning message.

HTH
Dave
 
So simple. Why did I not think of that. Thanks Dave.
 
Thank u Pat. I understand now why my method was not working.
 

Users who are viewing this thread

Back
Top Bottom