Deleting a record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I have a main form where the user enters a date and employee number, which then shows the relevant record/s in the subform
My problem is when I have tried too set up a delete button on the main form to delete any of the shown records
I have tried the wizard delete button, which doesn't work (probarly because there is no menu bar on the form)
I have tried "DoCmd.RunCommand acCmdDeleteRecord" "me.requery" which works fine but it doesn't delete the record shown on the form it deletes (I assume) the first record in the table :
Could someone please shine a light on this - thanks in advanc
 
DoCmd.RunCommand acCmdDeleteRecord will delete the current record of the
form that the command is run on. In this case it would be the current record
of the main form, not the subform. The same for Me.Requery. It would requery
the form that the command was run on. To work on the subform, you first have
to refer to the subform since you are running the code elsewhere.

How many records do you want to delete in the subform and by what criteria
do you want to do this deletion? What is the Record Source for the subform?

--
Wayne Morgan
Microsoft Access MVP


Wuelf said:
Hi,
I have a main form where the user enters a date and employee number, which
then shows the relevant record/s in the subform.
My problem is when I have tried too set up a delete button on the main
form to delete any of the shown records.
I have tried the wizard delete button, which doesn't work (probarly
because there is no menu bar on the form).
I have tried "DoCmd.RunCommand acCmdDeleteRecord" "me.requery" which works
fine but it doesn't delete the record shown on the form it deletes (I
assume) the first record in the table :(
 
Thanks wayne, setting the focus to the subform prior to deleting did the tric
I just want to delete any records that aren't correct one at a time, the subform record source is the same table as the main form
Cheers
 
Back
Top