Solved

Adding Datasheet and Form view to custom ribbon

Posted on 2011-09-12
9
873 Views
Last Modified: 2012-05-12
Hi, I am adding two buttons to custom ribbons and need some help please.  I have (through kind help from Experts Exchange) got the correct icons for datasheet and formview onto the ribbons, but I want to add the code without having to have the name of the form.  So that the icons can be used with any of the forms.  At present I have it working perfectly with a macro behind it that tells it to open a particular form but that wont do for all forms.  Unforunatly I dont know a lot of code but I can manage bits and pieces.  Any help with Datasheet and Formview would be appreicated or a toggle would be brilliant.  At present I have the following code on my ribbon -

<button id="btnShowFormView1" label="Learners Form View" size="large" imageMso="ViewsFormView" onAction="OpenLearnersFormView" getVisible="GetVisible" getEnabled="GetEnabled" />
0
Comment
Question by:AnnetteDavid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 36521332
Can you explain why this was ever required as Access already has menu/ribbon options to switch between views for the active form, as I'm sure you must know.
0
 

Author Comment

by:AnnetteDavid
ID: 36521573
Thanks for your reply, the person who was working on this built his own ribbons which really suited the database perfectly but I just wanted to add two more buttons, is this possible
0
 
LVL 77

Expert Comment

by:peter57r
ID: 36522315
Well it's going to depend on how the previous developer produced the custom ribbon and on which version of Access you are using.  So Version first please? (if it's not A2010 I shall be dropping out of this Q)

0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:AnnetteDavid
ID: 36522362
Using this in Access 2010 but first developed in 2007, code is below.

Thanks so much for trying to help.

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnRibbonLoad" loadImage="LoadImages">
  <ribbon startFromScratch="true">
    <tabs>
      <tab id="tabVirtualIT" label="Virtual-IT" getVisible ="GetVisible">
        <group id="grpOperations" label="Operations" getVisible ="GetVisible">
      <button id="btnHome" size="large" label="Virtual-IT Menu" imageMso="BlogHomePage" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="mcrmenu" getVisible="GetVisible" getEnabled="GetEnabled" />
        <button id="btnEmail" size="large" label="Email" imageMso="AttachItem" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="mcrEmail" getVisible="GetVisible" getEnabled="GetEnabled" />
      <button id="btnExcelfrom" size="large" label="Export to Excel" imageMso="ExportExcel" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="mcrexporttoexcel" getVisible="GetVisible" getEnabled="GetEnabled" />            
       <button id="btnPreview" size="large" label="Preview" imageMso="FilePrintPreview" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="mcrPreview" getVisible="GetVisible" getEnabled="GetEnabled" />
         <button id="btnPrint" size="large" label="Print" imageMso="FilePrint" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="mcrPrint" getVisible="GetVisible" getEnabled="GetEnabled" />
      <button id="btnPrintCards" size="large" label="Print All Student Cards" imageMso="FilePrint" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="mcrPrintAllStudentCard" getVisible="GetVisible" getEnabled="GetEnabled" />
<button id="btnClose" size="large" label="Close" imageMso="GroupColorModeClose" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="mcrClose" getVisible="GetVisible" getEnabled="GetEnabled" />

<button id="btnShowFormView1" label="Learners Form View" size="large" imageMso="ViewsFormView" onAction="OpenLearnersFormView" getVisible="GetVisible" getEnabled="GetEnabled" />

 <button id="btnShowDatasheet1" label="Learners Datasheet View" size="large" imageMso="AccessFormDatasheet"                  onAction="OpenLearnersDataSheetView" getVisible="GetVisible" getEnabled="GetEnabled" />

        </group>
        <group id="grpRecords" label="Records" getVisible ="GetVisible">
          <button id="btnFind" size="large" label="Find" imageMso="FindDialog" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="mcrFind" getVisible="GetVisible" getEnabled="GetEnabled" />
        <button id="btnFilter" size="large" label="Filter by selection" imageMso="AdpDiagramIndexesKeys" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="mcrFiltered" getVisible="GetVisible" getEnabled="GetEnabled" />
          <button id="btnRefresh" size="large" label="Refresh" imageMso="DataRefreshAll" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="mcrRefresh" getVisible="GetVisible" getEnabled="GetEnabled" />
          <menu id="mnuFilter" size="large" itemSize="normal" label="Filter" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" getVisible="GetVisible" getEnabled="GetEnabled" >
            <menu id="mnuFilterBySelection000" itemSize="normal" label="Filter By Selection" tag="RibbonName:=IDBERibbonCreator;inMenu:=mnuFilter;CustomPicture:=;CustomPicturePath:=" getVisible="GetVisible" getEnabled="GetEnabled" >
            <button id="btnA_Z" label="A-Z" tag="RibbonName:=IDBERibbonCreator;inMenu:=mnuFilterBySelection000;CustomPicture:=;CustomPicturePath:=" onAction="mcrfilter" getVisible="GetVisible" getEnabled="GetEnabled" />
            <button id="btnZ_A" label="Z-A" tag="RibbonName:=IDBERibbonCreator;inMenu:=mnuFilterBySelection000;CustomPicture:=;CustomPicturePath:=" onAction="mcrfilter" getVisible="GetVisible" getEnabled="GetEnabled" />
            </menu>
            <!--End menu (mnuFilterBySelection000) NOT delete this remark-->
          </menu>
          <!--End menu (mnuFilter) NOT delete this remark-->
        </group>
        <group id="grpReports" label="Reports" getVisible ="GetVisible">
      <button id="btnAdmin" size="large" label="Admin" imageMso="CreateReport" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="AdminReports" getVisible="GetVisible" getEnabled="GetEnabled" />
      <button id="btnHR" size="large" label="HR" imageMso="CreateReport" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="HrReports" getVisible="GetVisible" getEnabled="GetEnabled" />
      <button id="btnClients" size="large" label="Clients" imageMso="CreateReport" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="ClientReports" getVisible="GetVisible" getEnabled="GetEnabled" />
      <button id="btnEvents" size="large" label="Training Events" imageMso="CreateReport" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="TrainingEventReports" getVisible="GetVisible" getEnabled="GetEnabled" />
      <button id="btnLearners" size="large" label="Learners" imageMso="CreateReport" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="LearnerReports" getVisible="GetVisible" getEnabled="GetEnabled" />        
      <button id="btnQualifications" size="large" label="Qualifications" imageMso="CreateReport" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="QualificationReports" getVisible="GetVisible" getEnabled="GetEnabled" />
      <button id="btnSetas" size="large" label="Setas" imageMso="CreateReport" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="SETAReports" getVisible="GetVisible" getEnabled="GetEnabled" />
      </group>
      </tab>
      <tab id="tabAdministration" label="Administration" getVisible ="GetVisible">
      <group id="grpManage" label="Manage" getVisible ="GetVisible">
          <button id="btnBackUp" size="large" label="Back-UP" imageMso="FileBackupDatabase" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="Backup" getVisible="GetVisible" getEnabled="GetEnabled" />
          <button id="btnLink" size="large" label="Link Tables" imageMso="DatabaseAccessBackEnd" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="mcrLinktable" getVisible="GetVisible" getEnabled="GetEnabled" />
             <button id="btnArchive" size="large" label="Archive Old Learners" imageMso="RecordsDeleteRecord" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="ArchiveMacro" getVisible="GetVisible" getEnabled="GetEnabled" />
       </group>
      <group id="grpUploads" label="Loading" getVisible ="GetVisible">
          <button id="btnSeta" size="large" label="Seta Exports" imageMso="ExportAccess" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="UploadAgriInsetaForm" getVisible="GetVisible" getEnabled="GetEnabled" />
              <button id="btnUnitStd" size="large" label="Import Unit Standards" imageMso="ImportAccess" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="ImportLatestUnitStds" getVisible="GetVisible" getEnabled="GetEnabled" />
        <button id="btnExcel" size="large" label="Export To Excel" imageMso="ExportExcel" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="McrExportExcel" getVisible="GetVisible" getEnabled="GetEnabled" />
      </group>
      <group id="grpCompanyInfo" label="Update" getVisible ="GetVisible">
      <button id="btncompanyinfo" size="large" label="Company Info" imageMso="ExportAccess" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="mcrmaincompanyinfo" getVisible="GetVisible" getEnabled="GetEnabled" />
          <button id="btnEmployeeinfo" size="large" label="Employee Info" imageMso="ExportAccess" tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:=" onAction="mcrmainemployeeinfo" getVisible="GetVisible" getEnabled="GetEnabled" />
      </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>
0
 
LVL 77

Expert Comment

by:peter57r
ID: 36522496
If you are using A2010, then you can add built-in options to any ribbon just using the ribbon editor.

File>options>Customize Ribbon  will give you a dialog box which lets you add any standard feature to a ribbon.
0
 

Author Comment

by:AnnetteDavid
ID: 36527166
Hi thanks Peter, but this feature cannot see my own built in ribbons (just wish it was this easy).  Secondly if I was to use this feature and build everthing from scratch, cuold users who still have Access 2007 see the newly created ribbons
0
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 36530452
I thought this was going to be simple - and it should have been except that in testing I managed to make a small spelling mistake which i couldn't see and so I've been on a wild goose chase trying to find all sorts of explanations.

This is the basic code you need to add the view functions.

<group id="dbCustomGroup2" label="Another Custom Group">
          <control idMso="ViewsFormView" label="form view" enabled="true"/>
          <control idMso="ViewsDatasheetView" label="datasheetl" enabled="true"/>
        </group>

I suggest you start by adding it to your current XML just after the final <group/> and see what it looks like.

If necessary you can reposition it by cutting and pasting this code to any other corresponding position in the existing code.


Obviously I am unable to test this change with your code as your code is specific to your application.

0
 

Author Closing Comment

by:AnnetteDavid
ID: 36535069
You are just the best, it works fantastically and just what I needed.  I cannot say thank you enough. If I could give you more than 500 points I would. Have a brilliant day
0
 

Author Comment

by:AnnetteDavid
ID: 36535345
Hi Peter, I am going to add another question related to this one, thought I would let you know so you can get the points, dont want to take advantage.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question