DoCmd DoMenuItem

G

Guest

I have two forms and I am using the following code for deleting a selected
record but it works in one form but not in other. Any help will be greatly
appreciated.

DoCmd.DoMenuItem A_FORMBAR, A_EDITMENU, A_SELECTRECORD_V2, , A_MENU_VER20

DoCmd.DoMenuItem A_FORMBAR, A_EDITMENU, A_DELETE_V2, , A_MENU_VER20

Thanks.
 
D

Douglas J. Steele

Do yourself a huge favour, and stop using DoMenuItem. The help file for
Access 97 includes this comment "the DoMenuItem method has been replaced by
the RunCommand method. The DoMenuItem method is included in this version of
Microsoft Access only for compatibility with previous versions."

To learn more about RunCommand, see what Terry Wickenden has at
http://home.clara.net/tkwickenden/index.htm

To be honest, though, there are better ways to handle deletions than
RunCommand. My preference would be to use a Delete query.
 
M

missinglinq via AccessMonster.com

Doug's advice is sound, but as to why the code works in one form and not the
other; do you get an error message in the form where the code fails? If
AllowDeletions were set to No in the failing form, this would account for it
not working, as would the form being opened as Read Only.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 
G

Guest

Hi,

I tried RunCommand and I got the following message:

The command or action 'DeleteRecord' isn't available now.

Please help.

Thanks.
 

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

Top