Custom Ribbon and Reports

J

Joshann

I'm very new to Access 2007, and I'm trying to create a custom Ribbon.
Currently, I basically have the code for the sample in the USysRibbons table
like this:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon startFromScratch="true">
<tabs>
<tab id="dbCustomTab" label="A Custom Tab" visible="true">
<group id="dbCustomGroup" label="Reports">
</group>
</tab>
</tabs>
</ribbon>
</customUI>

I would like to know how to create buttons on the "Reports" group that will
open specific reports in my database. For example, I have a report called
rptDirectory. How do I make a button on the Ribbon that will open the
rptDirectory report?

I'm sure this is very elementary, but like I said, I'm new to Access 2007
and very new to trying to create a custom ribbon.

Thanks for any help you can provide.
 
J

Jeanette Cunningham

Here is some ribbon xml from one of my apps.
On the ribbon there is a button for Reports.
User clicks the button and the menu drops down with a list of reports to
select from.
Clicking a report on the list opens that report.


start of xml------------
<group id="grpCustReports" label="Reports" visible="true">

<menu id="mnuReports" size="large" label="Reports"
imageMso="ViewsReportView" itemSize="large">

<button
id="btnInvoiceJob"
label="Invoicing"
imageMso="CreateReport"
onAction="OnActionButton"
tag="Invoicing"
/>

<button
id="btnCurrentFortnightJob"
label="Job - Current Fortnight"
imageMso="CreateReport"
onAction="OnActionButton"
tag="Time with job details"
/>

<button
id="btnPreviousFortnightJob"
label="Job - Previous Fortnight"
imageMso="CreateReport"
onAction="OnActionButton"
tag="Time with job details"
/>

<button
id="btnCurrentFortnightHours"
label="Times - Current Fortnight"
imageMso="CreateReport"
onAction="OnActionButton"
tag="Time report"
/>

<button
id="btnPreviousFortnightHours"
label="Times - Previous Fortnight"
imageMso="CreateReport"
onAction="OnActionButton"
tag="Time report"
/>


<button
id="btnReportTask"
label="Tasks"
imageMso="CreateReport"
onAction="OnActionButton"
tag="task"
/>


<button
id="btnFix"
label="Database updates"
imageMso="CreateReport"
onAction="OnActionButton"
tag="Database updates"
/>

</menu>
</group>

end of xml------------
 
M

Mark Andrews

I have a few little articles on ribbons that I wrote when I started playing
with Access2007.
http://www.rptsoftware.com/help/microsoft_access_examples/

It might help. You need to get that excel file so you can look up all the
icons and there names and you need to get the basics for the
basRibbonCallbacks routine. Buttons are pretty easy.

Here are some examples:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
onLoad="onRibbonLoad">
<ribbon startFromScratch="true">
<tabs>
<tab id="tabHome" label="Home">
<group id="grpContacts" label="Contacts" visible="true">
<button id="ContactButton" label="Contacts"
imageMso="CreateTableTemplatesGallery" size="large"
onAction="OnActionButton" />
</group>
<group id="grpActivity" label="Activities" visible = "true">
<button id="ActivityButton" label="Activities" imageMso="FilePrepareMenu"
size="large" onAction="OnActionButton" />
</group>
<group id="grpEvents" label="Events" visible="true">
<button id="EventButton" label="Events" imageMso="AccessTableEvents"
size="large" onAction="OnActionButton" visible="true"/>
</group>
<group id="grpEmployees" label="Employees" visible="true">
<button id="EmployeeButton" label="Employees" imageMso="MeetingsWorkspace"
size="large" onAction="OnActionButton" />
</group>
<group id="grpReports" label="Reports" visible="true">
<button id="ReportButton" label="Reports" imageMso="PropertySheet"
size="large" onAction="OnActionButton" />
</group>
<group id="grpImport" label="Import Data" visible="true">
<button id="ImportButton" label="Import Data"
imageMso="SourceControlCheckIn" size="large" onAction="OnActionButton" />
</group>
<group id="grpAdmin" label="Options" visible="true">
<button id="OpvvvvvtionsButton" label="Setup/Options"
imageMso="OmsAccountSetup" size="normal" onAction="OnActionButton" />
<labelControl id="DateLabel" getLabel="getLabel" />
</group>
<group id="grpInfo" label="Info">
<button id="InfoButton" size="large" label="Info" imageMso="Info"
onAction="OnActionButton"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon startFromScratch="true">
<tabs>
<tab id="MyReport" label="Report Print and View Options">

<group idMso="GroupPrintPreviewPrintAccess" />
<group idMso="GroupPageLayoutAccess" />
<group idMso="GroupZoom" />


<group icvd="ListCommands" label="Print">
<button idMso="FilePrintQuick" keytip="q" size="large"/>
<button idMso="PrintDialogAccess"
label="Print Dialog"
keytip="d" size="large"/>
</group>

<group id="ExportCmds" keytip="e" label="Data Export">
<button idMso="PublishToPdfOrEdoc" keytip="p" size="large"/>

<button id="CreateEmail" label="Email Report (PDF)"
imageMso="FileSendAsAttachment"
enabled="true" size="large"
onAction= "=MySend()"/>
</group>


<group idMso="GroupZoom"></group>

<group id="Exit" keytip="x" label="Exit">
<button idMso="PrintPreviewClose" keytip="c" size="large"/>
</group>

</tab>
</tabs>
</ribbon>
</customUI>



Here's a pretty simple basRibbonCallbacks routine:
Option Compare Database
Option Explicit

Public gobjRibbon As IRibbonUI

Public Sub OnRibbonLoad(ribbon As IRibbonUI)
'Callbackname in XML File "onLoad"

Set gobjRibbon = ribbon

End Sub

Public Sub OnActionButton(control As IRibbonControl)
'Callbackname in XML File "onAction"
On Error Resume Next
Select Case control.ID
Case "ContactButton"
Call OpenForm("frmContactList", 1)
Case "ActivityButton"
Call OpenForm("frmActivityList", 1)
Case "EventButton"
Call OpenForm("frmEventList", 1)
Case "EmployeeButton"
Call OpenForm("frmEmployeeList", 1)
Case "ReportButton"
'Call OpenForm("frmReports", 1)
MsgBox "No reports available at this time. Contact RPT Software
to get reports added to this database.", vbOKOnly, "Sorry - No Report
Available"
Case "ImportButton"
DoCmd.OpenForm "frmImport", , , , acFormEdit, acDialog
Case "OptionsButton"
DoCmd.OpenForm "frmOptions", , , , acFormEdit, acDialog
Case "InfoButton"
DoCmd.OpenForm "frmHelpAbout", , , , acFormEdit, acDialog
End Select
End Sub

Public Sub GetLabel(control As IRibbonControl, ByRef label)
'Callbackname in XML File "getLabel"

Select Case control.ID
Case "DateLabel"
label = Format(Now(), "dddd, mmm d, yyyy")

End Select
End Sub
 
J

Joshann

Thank you very much!

Jeanette Cunningham said:
Here is some ribbon xml from one of my apps.
On the ribbon there is a button for Reports.
User clicks the button and the menu drops down with a list of reports to
select from.
Clicking a report on the list opens that report.


start of xml------------
<group id="grpCustReports" label="Reports" visible="true">

<menu id="mnuReports" size="large" label="Reports"
imageMso="ViewsReportView" itemSize="large">

<button
id="btnInvoiceJob"
label="Invoicing"
imageMso="CreateReport"
onAction="OnActionButton"
tag="Invoicing"
/>

<button
id="btnCurrentFortnightJob"
label="Job - Current Fortnight"
imageMso="CreateReport"
onAction="OnActionButton"
tag="Time with job details"
/>

<button
id="btnPreviousFortnightJob"
label="Job - Previous Fortnight"
imageMso="CreateReport"
onAction="OnActionButton"
tag="Time with job details"
/>

<button
id="btnCurrentFortnightHours"
label="Times - Current Fortnight"
imageMso="CreateReport"
onAction="OnActionButton"
tag="Time report"
/>

<button
id="btnPreviousFortnightHours"
label="Times - Previous Fortnight"
imageMso="CreateReport"
onAction="OnActionButton"
tag="Time report"
/>


<button
id="btnReportTask"
label="Tasks"
imageMso="CreateReport"
onAction="OnActionButton"
tag="task"
/>


<button
id="btnFix"
label="Database updates"
imageMso="CreateReport"
onAction="OnActionButton"
tag="Database updates"
/>

</menu>
</group>

end of xml------------





.
 
J

Joshann

Thank you also very much!

Mark Andrews said:
I have a few little articles on ribbons that I wrote when I started playing
with Access2007.
http://www.rptsoftware.com/help/microsoft_access_examples/

It might help. You need to get that excel file so you can look up all the
icons and there names and you need to get the basics for the
basRibbonCallbacks routine. Buttons are pretty easy.

Here are some examples:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
onLoad="onRibbonLoad">
<ribbon startFromScratch="true">
<tabs>
<tab id="tabHome" label="Home">
<group id="grpContacts" label="Contacts" visible="true">
<button id="ContactButton" label="Contacts"
imageMso="CreateTableTemplatesGallery" size="large"
onAction="OnActionButton" />
</group>
<group id="grpActivity" label="Activities" visible = "true">
<button id="ActivityButton" label="Activities" imageMso="FilePrepareMenu"
size="large" onAction="OnActionButton" />
</group>
<group id="grpEvents" label="Events" visible="true">
<button id="EventButton" label="Events" imageMso="AccessTableEvents"
size="large" onAction="OnActionButton" visible="true"/>
</group>
<group id="grpEmployees" label="Employees" visible="true">
<button id="EmployeeButton" label="Employees" imageMso="MeetingsWorkspace"
size="large" onAction="OnActionButton" />
</group>
<group id="grpReports" label="Reports" visible="true">
<button id="ReportButton" label="Reports" imageMso="PropertySheet"
size="large" onAction="OnActionButton" />
</group>
<group id="grpImport" label="Import Data" visible="true">
<button id="ImportButton" label="Import Data"
imageMso="SourceControlCheckIn" size="large" onAction="OnActionButton" />
</group>
<group id="grpAdmin" label="Options" visible="true">
<button id="OpvvvvvtionsButton" label="Setup/Options"
imageMso="OmsAccountSetup" size="normal" onAction="OnActionButton" />
<labelControl id="DateLabel" getLabel="getLabel" />
</group>
<group id="grpInfo" label="Info">
<button id="InfoButton" size="large" label="Info" imageMso="Info"
onAction="OnActionButton"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon startFromScratch="true">
<tabs>
<tab id="MyReport" label="Report Print and View Options">

<group idMso="GroupPrintPreviewPrintAccess" />
<group idMso="GroupPageLayoutAccess" />
<group idMso="GroupZoom" />


<group icvd="ListCommands" label="Print">
<button idMso="FilePrintQuick" keytip="q" size="large"/>
<button idMso="PrintDialogAccess"
label="Print Dialog"
keytip="d" size="large"/>
</group>

<group id="ExportCmds" keytip="e" label="Data Export">
<button idMso="PublishToPdfOrEdoc" keytip="p" size="large"/>

<button id="CreateEmail" label="Email Report (PDF)"
imageMso="FileSendAsAttachment"
enabled="true" size="large"
onAction= "=MySend()"/>
</group>


<group idMso="GroupZoom"></group>

<group id="Exit" keytip="x" label="Exit">
<button idMso="PrintPreviewClose" keytip="c" size="large"/>
</group>

</tab>
</tabs>
</ribbon>
</customUI>



Here's a pretty simple basRibbonCallbacks routine:
Option Compare Database
Option Explicit

Public gobjRibbon As IRibbonUI

Public Sub OnRibbonLoad(ribbon As IRibbonUI)
'Callbackname in XML File "onLoad"

Set gobjRibbon = ribbon

End Sub

Public Sub OnActionButton(control As IRibbonControl)
'Callbackname in XML File "onAction"
On Error Resume Next
Select Case control.ID
Case "ContactButton"
Call OpenForm("frmContactList", 1)
Case "ActivityButton"
Call OpenForm("frmActivityList", 1)
Case "EventButton"
Call OpenForm("frmEventList", 1)
Case "EmployeeButton"
Call OpenForm("frmEmployeeList", 1)
Case "ReportButton"
'Call OpenForm("frmReports", 1)
MsgBox "No reports available at this time. Contact RPT Software
to get reports added to this database.", vbOKOnly, "Sorry - No Report
Available"
Case "ImportButton"
DoCmd.OpenForm "frmImport", , , , acFormEdit, acDialog
Case "OptionsButton"
DoCmd.OpenForm "frmOptions", , , , acFormEdit, acDialog
Case "InfoButton"
DoCmd.OpenForm "frmHelpAbout", , , , acFormEdit, acDialog
End Select
End Sub

Public Sub GetLabel(control As IRibbonControl, ByRef label)
'Callbackname in XML File "getLabel"

Select Case control.ID
Case "DateLabel"
label = Format(Now(), "dddd, mmm d, yyyy")

End Select
End Sub




.
 

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