Right click?

B

Bill

I have a form where the display is a subset of
a recordsource that includes a name and address.
In the form's properties, I have "Record
Selectors" set to yes. I'd like to add to the
right-click dropdown an option to print a
report that will use fields taken from the
selected record. Currently, the dropdown
list includes "Cut", "Copy" and properties.

How do I do that? I don't see any right-click
events listed in the form's property table.

Thanks,
Bill
 
B

Bill

Thank you Albert, your suggestion is most
helpful.

If what I do is disable the "Record Selectors"
and substitute a button in its place, I think the
only impact would be to change the event from
double-click of the "Record Selectors" to a
single-click of the button. It might even be wise
to leave the user action as a double-click on the
button so that they don't have to change their
habits.

I'm not familiar with creating MS Access shortcut
menus, but I'd sure like to learn. If one were to
do that, are they then saddled with the task of
replacing the functional code behind what is there
by default? Like "cut", "copy", etc.?

Thanks,
Bill


----- Original Message -----
From: Albert D. Kallal
Newsgroups: microsoft.public.access.formscoding
Sent: Saturday, February 19, 2005 8:44 PM
Subject: Re: Right click?


If you are using a continues form, then all you have to do is place a
button
on the detail line, it will repeat.

The code behind the button to print the ONE detail record would be:

docmd.OpenReport "theReportWithDetils",acViewPrevew,,"id = " & me!id

And, if you don't want a preview..but want to send the one record to the
printer, then remove the above acViewPreview.

The above assumes you have made a nice report that displays all the fields
that you need from the one record.

You can see some screenshots of some continues forms with buttons that
repeat here:
http://www.members.shaw.ca/AlbertKallal/Articles/Grid.htm

I don't see any right-click
events listed in the form's property table.

You can also most certainly use a right click menu. A right click menu is
referred to as a "shortcut" menu. You specify which right click menu you
want to appear in the "other" tab of the forms properties sheet. You of
course have to create the right click menu first. Thus, if you are
familiar
in creating menus for ms-access, then this should be quite easy for you.

The "buttion" on the grid is likey less work..but either approach is quite
easy...
 
A

Albert D. Kallal

If you are using a continues form, then all you have to do is place a button
on the detail line, it will repeat.

The code behind the button to print the ONE detail record would be:

docmd.OpenReport "theReportWithDetils",acViewPrevew,,"id = " & me!id

And, if you don't want a preview..but want to send the one record to the
printer, then remove the above acViewPreview.

The above assumes you have made a nice report that displays all the fields
that you need from the one record.

You can see some screenshots of some continues forms with buttons that
repeat here:
http://www.members.shaw.ca/AlbertKallal/Articles/Grid.htm

I don't see any right-click
events listed in the form's property table.

You can also most certainly use a right click menu. A right click menu is
referred to as a "shortcut" menu. You specify which right click menu you
want to appear in the "other" tab of the forms properties sheet. You of
course have to create the right click menu first. Thus, if you are familiar
in creating menus for ms-access, then this should be quite easy for you.

The "buttion" on the grid is likey less work..but either approach is quite
easy...
 
A

Albert D. Kallal

I'm not familiar with creating MS Access shortcut
menus, but I'd sure like to learn. If one were to
do that, are they then saddled with the task of
replacing the functional code behind what is there
by default? Like "cut", "copy", etc.?

Actually, what you do is create you own custom menu. When you create a
custom menu, MANY of the options in the menu will be a copy of existing
features.

So, for example, we could create a new blank menu. We might want to keep the
cut/copy/paste. So, we would steal those menu items from existing (you can
do this via drag and drop with the mouse). And, for the "one" new feature,
then you have that button "call" your custom code.

The process is bit weird at first..then after a while, they actually become
fun to make. You can see some screen shots of custom menus I made here:

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


And, here is some info on how to make custom menus:

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

Bill

Well Albert, I think I've created a new "popup" (shortcut menu)
entitled "R-Click" and added the command cut, copy, paste.
Then, I opened the property sheet of a form and added that name
to the "Menu Bar" property. When I then attempt to switch the
form from design view to form view, I get the following diagnostic:

========================================================
Addrlst can't find the macro "R-Click."

The macro (or its macro group) doesn't exist, or the macro is new but hasn't
been
saved.
Note that when you enter the macrogroupname.macroname syntax in an argument,
you must specify the name the macro's macro group was last saved under.
========================================================

After I had put the cut, copy, paste commands in the new shortcut menu, I
looked
for the opportunity to save it, but I couldn't find any. The new menu is
there when
I go back to view -> toolbars -> custom -> [ ] shortcut menus -> Custom.

At this point I'm a bit lost, as (1) I don't know how to resolve whatever it
is I've
done to cause the above diagnostic and (2) How do I add a new command to
which I would run a subroutine in the codesheet of the form, e.g., like a
regular radio
button.

I must be close. Eh?

Thanks,
Bill
 
A

Albert D. Kallal

I must be close. Eh?

I think you are.

For each form, you can specify a menu bar (in the other tab), and, you can
also specify a short cut menu (that is what we want).

So, you set Shortcut Menu - Yes
ShortCut Menu Bar - here you use the drop down list to specify your right
click menu. If you done this right, you will see your list of shortcut menus
in the dropdown...
 
B

Bill

Okay Albert, I now have "R-Click" shortcut menu functioning
properly with the use of a right-click. (I tested the "Copy"
function by simply examining the contents of the clipboard.)

The only remaining question I have is: How do I get "my"
command inserted in the new menu. I don't see anywhere
in the "Custom" Command tab for shortcuts where I can
insert a new command. Then lastly, do a put the "call" in
the "Action" property of the command's property sheet?

Thanks a million. I can see where the use of shortcut menus
can indeed be sort of fun to use.

Bill
 
R

Rick Brandt

Bill said:
Okay Albert, I now have "R-Click" shortcut menu functioning
properly with the use of a right-click. (I tested the "Copy"
function by simply examining the contents of the clipboard.)

The only remaining question I have is: How do I get "my"
command inserted in the new menu. I don't see anywhere
in the "Custom" Command tab for shortcuts where I can
insert a new command. Then lastly, do a put the "call" in
the "Action" property of the command's property sheet?

While in customize mode for Menus/Toolbars right-click on the desired button or
menu item and select "Properties". In the Properties sheet you would enter the
name of your custom VBA function or macro in the "On Action" property.
 
B

Bill

Rick,
How do I get the menu item into the menu to begin with?
For example, I've already selected and inserted cut,
copy and paste into my new shortcut menu, but I don't
see anywhere in the "Command Tab"an option to add a
new user item.

Bill
 
P

PC Datasheet

Another option if you don't have room in a row to add a button or you just
don't want to clutter your form with a bunch of buttons is to use the Click
event of one or more of the fields in the row. In the click event, you can
have code to just open your report or you can open a opo-up form with
several options.
 
R

Rick Brandt

Bill said:
Rick,
How do I get the menu item into the menu to begin with?
For example, I've already selected and inserted cut,
copy and paste into my new shortcut menu, but I don't
see anywhere in the "Command Tab"an option to add a
new user item.


Just copy any existing item and then change the OnAction, Icon, and Text.
 
B

Bill

Currently I'm wading through the nuances of shortcut
menus. See my last reply to Rick Brandt and/or the
thread starting with Albert's first post.

Thanks,
Bill
 
B

Bill

Okay Rick, I think that might get me over the last
obstacle. I'll post back when I've successfully
run some VBA code in the codesheet.
Thanks,
Bill
 
B

Bill

In the property sheet of a shortcut menu item what do
I set the "OnAction" to call a codesheet subroutine?
I've tried "Call subname arg" and just "subname arg",
but I get diagnostics about not finding a macro or function
when I click on the shortcut item.

Thanks,
Bill
 
P

PC Datasheet

To start, you need to put a function or sub in a standard module for what
you want the menu item to do. Assuming you want to open your report, put
something like the following in a standard module:
Sub MySubToOpenReport()
On Error Resume Next
DoCmd.OpenReport "MyReport", acPreview
End Sub

Now in the OnAction property you need to tell Access that when the menu item
is selected, it needs to run a specific function or sub. In our case, put
the following in the OnAction property:
=MySubToOpenReport()

Note that the equal sign is needed and also the parameter parantheses are
needed. If you omit either, you will get an error message.
 
B

Bill

Okay, it never occurred to me about the "=" in front of the
function name. Anyway, having properly adjusted the syntax
in the OnAction property, I was able to run code in the
function.

I'm confused by some terms: What's the difference between
a "general module" and a "standard module"? The function I
successfully executed was "located" in the codesheet of the
form, not coded in a "module" as one views the database
objects, e.g., Tables, Queries, Forms, Reports, Pages,
Macros and "Modules".

This latest caper has proven to be very valuable, so I'm
grateful to all those that contributed to my education on
the subject of shortcut menus.... thanks!

Bill
 
A

Albert D. Kallal

I'm confused by some terms: What's the difference between
a "general module" and a "standard module"?

I think both terms are generally the same thing. Thus, you can (could have)
put the code in a standard module that you create.

However, in your case, since you are fetching values from the form..and the
code is ONLY for that one form, then it would NOT make sense to put your
code in a general module..but makes sense to put it in the forms module.
The function I
successfully executed was "located" in the codesheet of the
form

Excellent...that is the likely the best place to have put the code.

However, if you were making a right click menu for "many" forms to do
something, then obviously, you would have chosen to put the code in a
general module (note that ms-access first looks for the function name in the
currently active form, and if not found..then it looks for the name in a
standard module).
This latest caper has proven to be very valuable, so I'm
grateful to all those that contributed to my education on
the subject of shortcut menus.... thanks!

You are most welcome. And, that link I gave you on making menus was a link
into the "middle" of a good book. While that book was for a97, you actually
might find it very useful to try reading some other chapters. The book
starts here:

http://www.microsoft.com/accessdev/articles/bapp97/toc.htm
 

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

Similar Threads


Top