Main Menu Command Button

G

Guest

Hi Everyone, Could someone please help me to achieve the desired requirements
of this command button. I have a switchboard which has a button to open the
form 'ALLFORM'. On allform I have a button which I would like to do several
things dependant on the circumstances. The form opens in edit mode at last
record.

1. If the user has just opened the form and wishes to go straight back to
the switchboard, I would like them to be able to click the ReturntoMainMenu
button and go straight back.

2. If they have already selected either 'AddNewRec' or 'EditRec' or 'DelRec'
command button but change their mind, I would like them to click the
'ReturntoMainMenu' button so it gives a message (as below) select Yes or No
and either undo all changes and return to switchboard for Yes or puts them
back on the form for No. Similarly if they have selected any of the 3 above
buttons and entered some data the same should still apply ie give message,
clear data & return to main menu for yes or put them back to the form for No.

With the help of this forum I have got the button to do point 2 above. I
have tried to add code to get point 1 to work but with no luck, any help is
appreciated.

Regards Sue (current working code below)

Dim stDocName As String
Dim stLinkCriteria As String

If Me.AddNewRec.Enabled Then
If MsgBox("THIS WILL CANCEL ANY CHANGES ON CURRENT FORM AND RETURN TO
MAIN MENU", vbQuestion + vbYesNo) = vbNo Then
'DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
DoCmd.CancelEvent
Else
stDocName = "Switchboard"
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End If
 
B

BillCo

this should do the trick:

if me.clean then
docmd.close
else
if msgbox("undo stuff?", vbYesNo) = vbYes then
me.undo
docmd.close
end if
end if
 

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