DoMenu Item for deleting records

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.
 
G

Guest

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...
 
D

Dirk Goldgar

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.
 
G

Guest

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.
 
D

Dirk Goldgar

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.
 
G

Guest

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:
 
G

Guest

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:
 
G

Guest

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:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top