web 2.0


Office 2010 Cancel on load

Microsoft Office 2010 new features include "cancel on load". This is a little "Cancel" button on the right-hand bottom corner of the application splash screen which can be used to cancel the loading of the application:


Figure 1: Cancel on load

Tags: , , , ,

Microsoft Office | Microsoft Office 2010

Acess 2007: Introduction to subdatasheets

A subdatasheet is useful when you want to see the information from several data sources in a single datasheet view. For example, in the Northwind sample database, the Orders table has a one-to-many relationship with the Order Details table as shown in picture 1 below:


Picture 1: Relationship between the Order Details and Orders Tables

If the Order Details table is added as a subdatasheet in the Orders table, you can view and edit data such as the products included in a specific order (each row) by opening the subdatasheet for that Order. Picture 2 shows this scenario:


Picture 2: Relationship between the Order Details and Orders Tables

In this video tutorial, you will learn how to create queries and link them as subdatasheets. You will also learn how to aggregate the order details so that you can view the consolidated data for each employee.

Tags: , , ,

Microsoft Access

Building custom toolbars in MS Access - Part 3

This article is the third part of the series on building custom toolbar in MS Access.

In this article I will show to execute actions and keyboard shortcuts using the OnAction property and the Execute method. Furthermore, I will show how to create shortcuts in Access.

The difference between OnAction and Execute is that OnAction executes a command that we determined through a procedure whereas Execute executes an internal command such as print. However, Execute is activated when we create the button, thus, we will use the button ID to execute the command. In other words, we will define the button such that it acts as if we had clicked on the Relationships button under the Tools menu.

Firstly, let us create the code that will build our menu:

Public Const MENUACCESS As String = "Menu Bar"

Sub executeMenus()

   Dim mnu     As CommandBarPopup

   Dim btn     As CommandBarButton

   

   On Error Resume Next

   CommandBars(MENUACCESS).Controls("Execute Commands").Delete

   Set mnu = CommandBars(MENUACCESS).Controls.Add _

    (Type:=msoControlPopup, before:=1)

    mnu.Caption = "Execute Commands"

   Set btn = mnu.Controls.Add(Type:=msoControlButton)

    With btn

     .Caption = "Example OnAction"

     .FaceId = 1018

     'Refers to the procedure to be executed

     .OnAction = "Message"

    End With

   Set btn = mnu.Controls.Add(Type:=msoControlButton, ID:=523)

    With btn

     .Caption = "Example Execute"

     .FaceId = 523

     'This option is commented as we will use its ID to execute

     'the command we want

     '.Execute

    End With

End Sub

The new menu should look like this:


Figure 1 – OnAction property and Execute method

The FaceID choice is up to the reader.

Note that for the OnAction we put the name of the procedure to be executed when the button is clicked. However, on the Execute instance we refer to the command to be executed by using its ID. Given that the OnAction property needs a procedure, we shall use the example below as a simple way to get the button up-and-running:

Sub Message()

   MsgBox "There is nothing under this button to be executed.", _

    vbInformation

End Sub

When we click the button the message below is shown to the user:


Figure 2 – MsgBox called by the OnAction property

As for the second button, when we click it, the Relationships window is open:


Figure 3 – Relationships windows opened through the Execute method

Once we have defined the ID of the command, the Execute method becomes redundant, as when we click on the button the command is executed. However, there may be situations when you wish to have the command executed immediately.

The above commands are executed through cliks, however, we can also add keyboard shortcuts. These shortcuts will require that you only press a few key combinations to execute the command you want.

This will be discussed in my next article.

Tags: , , ,

Microsoft Access | Microsoft Access - VBA

Customizing the Ribbon: startFromScratch and Tab visibility

If you start from scratch, then using the getVisible attribute to show/hide a tab will not work, since you'd have to rebuild the functionalities for the elements. However, an option would be to simply start all tabs hidden and then show/hide as you go along, this would avoid the frustrating of having to rebuild each tab using XML to work with them.

Remember that working with startFromScratch does not stop the user from hitting shortcut keys to access certain functionalities (at least for now), so it is pretty much pointless to start from scratch except for the fact you’d have all the tabs and certain commands hidden from the outset. Here’s an option to work with an Excel file. Use the following XML to built your own custom tab:

<customUI
  xmlns="http://schemas.microsoft.com/office/2006/01/customui"
  onLoad="rxRibbon_onLoad">

  <ribbon
   startFromScratch="false">
   <tabs>
    <tab
     idMso="TabHome"
     getVisible="TabHome_getVisible"/>
   <tab
     id="rxTab0"
     label="My Custom Tab">

     <group
      id="rxGrp0"
      label="My Custom Group">

      <toggleButton
       id="rxtglBtn0" getLabel="rxtglBtn0_getLabel"
       imageMso="HappyFace"
       size="large"
       onAction="rxtglBtn0_Click" />
     </group>
    </tab>
   </tabs>
  </ribbon>
</customUI>

You can then write some code in your workbook as follows to control visibility (place code in a standard module):

 

Public rx_oRibbon             As IRibbonUI
Public blnGetLabelState       As Boolean
Public blnHomeTabVisibility   As Boolean

Sub rxRibbon_onLoad(ribbon As IRibbonUI)
  Set rx_oRibbon = ribbon
  blnGetLabelState = False
  blnHomeTabVisibility = False
End Sub

Sub rxtglBtn0_getLabel(control As IRibbonControl, ByRef returnedVal)
  Select Case blnGetLabelState
    Case True
      returnedVal = "Hide 'Home Tab'"
    Case False
      returnedVal = "Show 'Home Tab'"
  End Select
End Sub

Sub TabHome_getVisible(control As IRibbonControl, ByRef returnedVal)
  returnedVal = (blnGetLabelState)
End Sub

Sub rxtglBtn0_Click(control As IRibbonControl, pressed As Boolean)
  blnGetLabelState = pressed
  rx_oRibbon.Invalidate
End Sub

Tags: , , , , ,

Microsoft Office | Microsoft Office - VBA | Ribbon