Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why aren't menus used much? 1

Status
Not open for further replies.

RayDru

Programmer
Mar 25, 2005
5
0
0
US
I have been trying to research menus and don't find much info. I would think users are more familiar with menus than switch boxs. The only menu I haven't figured out is print, as it won't print what you want. There must be a reason and I would be interested in knowing.
Thanks,
Ray D
 
Menus are very powerful tools to use on a form.

To program the menus you need to use the CommandBars object - see help for the full object model. Using this object you can capture what option the user has selected and carry out some action. You can also create context sensitive shortcut menus when the user right-clicks on a a forms control.

If you only use the built in menus then you need to bear in mind that all the options available on the menu are based on what the active form/report/control is. For example if you are trying to filter a sub-form but the active control is on the main form, only the main form will be filtered.

If you are having problems printing from the menu then it is probably better to program the menu bar and then use the print object or Docmd.OpenReport command to carry out the action you want.
Justin
 
How are ya RayDru . . . . .

I have very few DBs I've designed that don't have their own customized Menus & ToolBars, and I totally agree with [blue]jatighe[/blue]
RayDru said:
[blue]I have been trying to research menus and don't find much info.[/blue]
Research in what way?

Looking for what?

Calvin.gif
See Ya! . . . . . .
 
The research has been on how to print a report from a form print menu. But I have also been looking for samples, I have not found a single sample that uses menus, everyone uses buttons.
Thanks,
Ray
 
RayDru said:
[blue]The research has been on [purple]how to print a report from a form print menu.[/purple][/blue]
There is no form print menu, unless you mean the print section in the standard [blue]File Menu[/blue] . . .

Now . . . . you can [blue]add custom menu commands[/blue] to existing or customized menu bars to do what you want (instead of buttons).You can even add your own menu listing. The technique is basically the same. The customized menu command runs code that performs your task. This is whats vague . . . . Do you want to:

[ol][li]Print a form as a report?[/li]
[li]Print a specific report?[/li]
[li]Open a form with a list of reports and select from there?[/li][/ol]

Calvin.gif
See Ya! . . . . . .
 
Thanks for the answers,
I want to print a specific report from a form after it is filled out. The print menu just prints the form, which I understand, but I don't know how to change it.
Ray D
 
OK RayDru . . . . .

I'm trying to edit instructions now (before I fall asleep).

[ol][li]Do you want to [blue]print directly[/blue] or do you wanna go to [blue]Print Preview[/blue]?[/li]
[li]What are the names of the form & report?[/li][/ol]
If I don't finish soon, I'll get it to you in the mourning.

Calvin.gif
See Ya! . . . . . .
 
I don't need print preview.
The form name is frmRfi
The report is rptRfi
and good god get some sleep!!
Ray D
 
everyone uses buttons
With button the action is triggered with one user's click, with menu at least two clicks + mouse movement is needed.
how to print a report
Take a look at the DoCmd.OpenReport method.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
OK RayDru . . . Here we go . . .

[ol][li]Right-Click the Menubar. Click [blue]Customize[/blue] - [blue]Commands Tab[/blue].[/li]
[li]In [blue]Categories[/blue] click [purple]File[/purple].[/li]
[li]In [blue]Commands[/blue], find the [purple]print icon[/purple] and [blue]drag/drop[/blue] to the right side of the last menu on the MenuBar.[/li]
[li]Right-Click the button you just installed.[/li]
[li]In the [blue]Name:[/blue] at the top enter [purple]Rpt1[/purple].[/li]
[li]Further down make sure [purple]Image and Text[/purple] is checked.[/li]
[li]Further down click [purple]Properties[/purple].[/li]
[li]Change the [purple]Caption:[/purple] to the text you want to see in the button. [blue]Print Report[/blue] for example.[/li]
[li]Remove any [purple]Shortcut Text:[/purple][/li]
[li]Add a [purple]ScreenTip Text:[/purple] if you like. This is what appears if you hover the mouse over the button.[/li]
[li]In the [purple]On Action:[/purple] enter [purple]=PrtRpt1()[/purple]. This is the name of the routine that will run when you click the button.[/li]
[li]Close the [blue]File Control Properties[/blue].[/li]

Now you could leave the button ([blue]PHVs suggestion[/blue]). If you want it in a menu continue with the steps.

[li]Your gonna drag/drop the button to the [blue]print section[/blue] of the [blue]File Menu[/blue]. Before you do, read the following.

When you drag/drop, first drag and hover over the File Menu on the Menu Bar. It will expand. Move down to the print section (a black line will show you where you are) and drop at the top of the print section. If you miss, you can drag/drop up & down to get it right.
Note: if for any reason the menu closes up on you, just left-click the file menu to drop it again.

Perform the drag/drop.[/li]
[li]Right-Click the [blue]button below yours[/blue] and put a check in [purple]Begin a Group[/purple].[/li]
[li]Close the [blue]Customize[/blue] window.[/li]
[li]If you click on the button now. you should get an error about not finding [blue]PrtRpt1[/blue].[/li][/ol]

In a module in the modules window, copy/paste the following code:
Code:
[blue]Public Function PrtRpt1()
   Dim Msg As String, Style As Integer, Title As String
   Dim DL As String, Criteria As String
   
   DL = vbNewLine & vbNewLine
   Criteria = "[Name]='frmRfi' AND [Type] = -32768"
   
   If Not IsNull(DLookup("[Type]", "MSysObjects", Criteria)) Then
      If IsOpenForm("frmRfi") Then
         DoCmd.OpenReport "rptRfi", acViewNormal
      Else
         Msg = "Can't Print Report!" & DL & _
               "Form 'frmRfi' is not open!" & DL & _
               "Open the form and try again . . ."
         Style = vbCritical + vbOKOnly
         Title = "Form Not Open Error! . . ."
         MsgBox Msg, Style, Title
      End If
   Else
      Msg = "Form 'frmRfi' Not In This Database!"
      Style = vbCritical + vbOKOnly
      Title = "Form Object Missing Error! . . ."
      MsgBox Msg, Style, Title
   End If
   
End Function

Function IsOpenForm(frmName As String) As Boolean
   Dim cp As CurrentProject, Frms As Object, Criteria As String
   
   Set cp = CurrentProject()
   Set Frms = cp.AllForms

   If Frms.Item(frmName).IsLoaded Then
      If Forms(frmName).CurrentView > 0 Then IsOpenForm = True
   End If
   
   Set Frms = Nothing
   Set cp = Nothing

End Function[/blue]
[purple]Thats it . . . give it a whirl & let us know . . .[/purple]

Calvin.gif
See Ya! . . . . . .
 
Wow!!!!
Help does not get better than that. You don't know how long I have been searching for that answer. It will be Monday before I can try it, but I will let you know how it goes.
Ray D
 
Aceman nice tip.

Life's a journey enjoy the ride...

jazzz
 
Hey,

If i can get my FAQ read on toolbars, i'll be happy.

When i first started using Toolbars i wanted more icon's then I saw in the Access toolbar menu..

Check out: faq705-5152 in Microsoft Access Modules(VBA Coding).


Mark P.
Providing Low Cost Powerful Point of Sale Solutions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top