Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command button problems

Status
Not open for further replies.

barit

Technical User
Jun 29, 2004
38
CA
I am attempting to add command buttons to a main form that control both the actions on the sub form. For example I want to add a delete button on the main form that would delete a record on the subform. Equally, I would like an UNDO button on my main form that would undo a record on the subform.

When I attempt to add buttons, they do not work. However, if I use the menu/toolbar to accomplish this task it works.

After much trying and guess work I have managed to make it so my delete button on the main form works. This was done by:

1. setting the focus back to the subform in the On click event on the command button. (me.subformname.SetFocus)
2. changing control names used in If...Then...Else statements that are part of my code to reflect subform location eg. If (Me!Subformname.Form![fieldnameonsubform])

This is all great and setting the focus back to the subform seems to work for other command buttons, but I still am having problems with my Undo button.

In the case of undo, once again I can complete the task from the menu/taskbar however from a command button on my form I get message telling me to complete the required data entry for the record (This is an error message I have set up in the subform to ensure complete entry of info prior to exiting the record). If I want to undo a record, how do I get the focus moved to the main form so I can complete the undo task?

I really would appreciate some suggestions on how to deal with the command buttons. Thanks in advance
 
Hi

I could be wrong, but..

I do not think you will be able to do this, the subform record is save as soon as you move focus back to your mainform by clicking on your undo button, thus triggering the before and after update events of your subform, which presumably trigger your error message(s)

You do realise that your users can undo on the sub form by pressing Esc?




Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top