Custom Menus

  • Thread starter Thread starter Tony Williams
  • Start date Start date
T

Tony Williams

First off I'm a bit of a newbie at Access, most of what I've learned is from
books and from you guys on here.

I have a database that I would like to create a custom menu bar. I've looked
at the help files and it appears that the actions behind the menu items can
be macros. However I have eg code behind a Save button on a form that I want
to put behind the Save menu item. Can I do this? If so can someone point in
1,2, 3 steps where I can find some good tutorial or give me any pointers.For
example how would I rewrite this code which is behind my Save button to work
behind the File-Save option on a customised menu bar:
Private Sub cmdsave_Click()
On Error GoTo Err_cmdsave_Click

If Me.NewRecord Then
If vbNo = MsgBox("Are you sure you want to save this record?", 36, "Enter
New Record") Then
Me.Undo
[DocNametxt].SetFocus
End If
End If
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_cmdsave_Click:
Exit Sub

Err_cmdsave_Click:
MsgBox Err.Description
Resume Exit_cmdsave_Click

End Sub

TIA
Tony Williams
 
You simply make the form function public.

Like:

Public Function MySave

If Me.NewRecord Then
If vbNo = MsgBox("Are you sure you want to save this record?",_
36, "Enter New Record") Then
Me.Undo
[DocNametxt].SetFocus
End If
End If

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

End Function.


In the custom menu bars on-action setting, you simply go:

=MySave()

That is it.

So, your custom menus will and can run code in your form, or in a standard
module.

You do need to make the function public for the above to work.

For some reading on why I think menus are good, check out:

http://www.attcanada.net/~kallal.msn/Articles/UseAbility/UserFriendly.htm

And, some more neat screen shots of menu bars can be seen at:

http://www.attcanada.net/~kallal.msn/Rides/Rides.html

And, for some tutorials on how to use menus...you can check out:

http://www.microsoft.com/Accessdev/articles/bapp97/chapters/ba01_6.htm
 
Back
Top