NEED DETAILED HELP - MENU BAR and MENU COMMANDS!!!!!!!!!

G

Guest

Hello,

I am trying to create a menu bar the will do several things...

1. Return/Open to main menu form.
2. Export to Office (they will contain two menu commands; one to export to
Word and the other to Export to Excel)

3. Export to Snapshot (.snp or .rtf file)


4. Exit Application (Allow user to exit Access)

Does anyone have a solution how to create a menubar that will perform all 4
things.

Thanks,
 
A

Albert D. Kallal

I would say that 90% of my custom menu bars call, and run my VBA code.

All you need to do is make the code (a function) public, and then simply
place the function name in the buttons on-action event code.

Further, likely often you will have specific code to a particular form, and
once again, you simply declare those functions (in that form) as public.

The syntax to call the code then is:

=YourFunctionName()

Often, (if not most of the time), you code you call will need to pick up
some information about he current screen etc. So, my code most of the time
starts out, and grabs the current screen name. I use:

Public Function AskInvoicePrint()

Dim tblgroupid As Long
Dim frmActive As Form

Set frmActive = Screen.ActiveForm

tblgroupid = frmActive.frmMainClientB.Form!ID

If frmActive.InvoiceNumber = 0 Then
frmActive.InvoiceNumber = nextinvoice
frmActive.Refresh
End If

DoCmd.OpenForm "guiInvoicePrint", , , "id = " & tblgroupid

End Function

The above is code that the invoice print button runs. note how I right away
pick up the active form. After that, I can easily ref the forms object as if
the code was running much like the code would if put behind a button on the
form. In the above example, I also check if a invoice number has been
generated before printing. And, the Refresh forces a disk write if in fact I
do change the invoice number. And, in addition the above clip also passes
the currently selected sub-form item that the invoice print form needs.

Also, if the code you write is for the particular form, then as mentioned,
you can simply place the code into the forms module code. There is no need
to pick up the active screen...and you can use me. as you
always used.

If you want to see some sample menu bars, and why I use them, you can read
the following:

http://www.members.shaw.ca/AlbertKallal/Articles/UseAbility/UserFriendly.htm

As for a menu option that "returns" to the main form? I assume you just
want to close the current form them?

Try downloading and running the 3rd example at my following web site that
shows a hidden ms-access interface, and NO CODE is required to do
this....but just some settings in the start-up.

Check out:

http://www.members.shaw.ca/AlbertKallal/msaccess/DownLoad.htm

After you try the application, you can exit, and then re-load the
application, but hold down the shift key to by-pass the start-up options. If
want, you can even disable the shift key by pass. I have a sample mdb file
that will let you "set" the shift key bypass on any application you want.
You can get this at:
http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html

The above example has a "close" option in the menu bar that closes the
current form....
 
B

Bongard

I said:
Hello,

I am trying to create a menu bar the will do several things...

1. Return/Open to main menu form.
2. Export to Office (they will contain two menu commands; one to export to
Word and the other to Export to Excel)

3. Export to Snapshot (.snp or .rtf file)


4. Exit Application (Allow user to exit Access)

Does anyone have a solution how to create a menubar that will perform all 4
things.

Thanks,

Hi,
I would suggest creating a macro that does each of the actions you
described. The open/return is very easy. Just make the macro close the
current form (Whatever it is) and open the main menu form.

The second two: exporting to word and Excel can also be done using the
macro (SendObject) then with the macro options select what you want
exported, to where and what file type it will be etc...

The snapshot option is also available in the SendObject macro.

Exit application is also a macro "Quit" This exits MS access when
clicked, and I believe you can have it prompt you or autosave any
changes that have been made to your database.

If you want your menu bar to do all four of these things at once just
create the macros that I describe and then create a "MasterMacro" that
runs all of these macros. If you choose to create a new macro you will
have to make it's action "RunMacro" and have it run all of the macros
you just created.


Hope this helps!
Brian
 

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