DoMenu Item for deleting records

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

Guest

Hi,

I am trying to delete a record in a subform "Continius" form. Records will
not delete.

I have used RunCommand acCmdDeleteRecord that will not work.
I use to use this code in 2.0
DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_SELECTRECORD_, A_DELETE

How should this be in 2003?

Best regards and thanks.
 
Hi Flemming,

As a simple method to create a command button to delete a record I suggest
using the controls wizard. That is
with the control wizard active,
add a command button to your form
From the categories list select 'Record Operations'
From the actions list select 'Delete Record'
Click >>Next and continue...
 
Flemming said:
Hi,

I am trying to delete a record in a subform "Continius" form. Records
will not delete.

I have used RunCommand acCmdDeleteRecord that will not work.
I use to use this code in 2.0
DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_SELECTRECORD_, A_DELETE

How should this be in 2003?

Best regards and thanks.

If RunCommand acCmdDeleteRecord doesn't work, there must be something
confusing Access as to which record you want to delete, or whether the
current form has any records -- or else the subform doesn't allow
deletions for some reason. Where are you trying to execute this code?
Is it from a command button on the main form? If so, you're going to
have to set the focus back to the subform so that Access knows that's
the record you want to delete.
 
If the delete button is on the main form then before you run the delete line,
set the focus to the sub form
Me.SubFormName.setFocus
DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_SELECTRECORD_, A_DELETE
==================================================
If it doesn't help, check the properties of the sub form, if the can delete
set to true

==================================================
Try and delete the records, by selecting the records and pressing delete,
does that works
If not then try and delete the records by running only the SQL, without the
form.
 
Ofer said:
If the delete button is on the main form then before you run the
delete line, set the focus to the sub form
Me.SubFormName.setFocus
DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_SELECTRECORD_, A_DELETE

But don't use that old Access 2.0 code. If you *must* use DoMenuItem,
at least use more modern constants, like those generated by the command
button wizard. However, RunCommand acCmdDeleteRecord is better.
 
Hi Jonathan,

Thank you.

I am running the code on delete behind the form. The solution turned out to be
DoCmd.RunCommand acCmdSelectRecord.

Regards,

"Jonathan" skrev:
 
Hi Ofer,

Thank you.

I am running the code on delete behind the form. The solution turned out to be
DoCmd.RunCommand acCmdSelectRecord.

Regards,
Flemming

"Ofer" skrev:
 
Hi Dirk,

Access didn't know which records to delete.

I am running the code on delete behind the form. The solution turned out to be
DoCmd.RunCommand acCmdSelectRecord.

Regards,
Flemming

"Dirk Goldgar" skrev:
 
Back
Top