Link to home
Start Free TrialLog in
Avatar of AnnetteDavid
AnnetteDavidFlag for South Africa

asked on

Adding Datasheet and Form view to custom ribbon

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" />
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

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.
Avatar of AnnetteDavid

ASKER

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
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)

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>
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.
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
ASKER CERTIFIED SOLUTION
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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.