Menu In Access 97

B

Bob Watson

I used the following instructions to place another SUBMENU item
onto an existing drop down menu ... However, I could cause no action to
take place when it was clicked.

Comparing my new submenu items to those already there, the
one clear difference is that mine did not have an HelpContextID
nor a Help File (on right clicking/properties) ... other than
that I can see no difference.

Any help would be appreciated ... here is the method I used:

View/Toolbars/Custom and the customize box appeared

On the COMMANDS tab
Left Right
File Custom

I drug the "Custom" to the existing drop down menu and a
new item (called Custom) showed up. Then I right-clicked
this new "Custom" to change its name and to enter
an existing report as its parameter.

Then I closed the Customize Dialog Box and when I click
this new menu item nothing happens. I can, by the way, change
the "parameter" on existing buttons and this report runs fine.

Any help would be greatly appreciated.

Thanks,
Bob Watson
 
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

So, you don't need "code" to create a custom menu. You use the customize
menu options..and layout menus and buttons as you please. You then just put
the name of the function you want to call in the on-action as above....


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.members.shaw.ca/AlbertKallal
 
B

Bob Watson

Ok - thanks I'm making progress. I created a new Public Function
in an existing module. The function looks like this:

Public Function ShowStatUsingCity()
DoCmd.OpenReport "rStatUsingCityQuery"
End Function

Then on the right-click-properties of the new Custom button,
I put
=ShowStatUsingCity()

Now, if you go to the Reports tab and click
rStatUsingCityQuery
it works perfect. Fires up a parameter box, takes your
parameter and then GIVES YOU THE REPORT ON THE SCREEN.

BUT, WITH THIS BUTTON, it first fires up a printing dialog
box
Printing
Now printing
rStationUsingCityQuery to the
Lexmarki 3200 Color Jetprinter onLPT1
CANCEL

AND THEN, it gives you the parameter box and does not
give you the report on the screen but rather sends it
to the printer queue.

How do I fix this??

THanks,
Bob
_____________________________
 
D

david epsom dot com dot au

acViewNormal prints the report immediately. If you leave this argument
blank, the default constant (acViewNormal) is assumed.


Access 97 had a very good help system. Put your mouse
curser on
OpenReport
and press the F1 key to see the help screen for OpenReport:

"
DoCmd.OpenReport reportname[, view][, filtername][, wherecondition]

The OpenReport method has the following arguments.

Argument Description
reportname A string expression that's the valid name of a report in the
current database.
If you execute Visual Basic code containing the OpenReport method in a
library database, Microsoft Access looks for the report with this name first
in the library database, then in the current database.
view One of the following intrinsic constants:
acViewDesign
acViewNormal (default)
acViewPreview
acViewNormal prints the report immediately. If you leave this argument
blank, the default constant (acViewNormal) is assumed.

"
 

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