Option Compare Database
Option Explicit

Public objRibbon As IRibbonUI
Private strUserTxt As String
Private isCtlEnabled As Boolean


' callback for the onLoad attribute of customUI
Public Sub RefreshMe(ribbon As IRibbonUI)
    Set objRibbon = ribbon
    isCtlEnabled = False
End Sub

Public Sub getEditBoxText(control As IRibbonControl, _
                          ByRef text)
    text = UCase(strUserTxt)
End Sub

Public Sub onGetEnabled_Health(control As IRibbonControl, _
                                ByRef enabled)
    enabled = isCtlEnabled
End Sub

Public Sub onFullNameChangeToUcase(ByVal control As IRibbonControl, _
                            text As String)
        
    If text <> "" Then
        strUserTxt = text
        objRibbon.InvalidateControl "txtFullName"
        isCtlEnabled = True
    Else
        isCtlEnabled = False
    End If
    objRibbon.InvalidateControl "chkHealth"
End Sub


Public Sub OnLoadImage(imgName As String, ByRef image)
    Dim strImgFileName As String
    strImgFileName = "C:\Acc07_ByExample\images\" & imgName
    
    Set image = LoadPicture(strImgFileName)
End Sub

Public Sub OnGetImage(ctl As IRibbonControl, ByRef image)
 Select Case ctl.ID
  Case "btnRedStar"
    Set image = LoadPicture("C:\Acc07_ByExample\images\redstar.gif")
  Case "glHolidays"
    Set image = LoadPicture("C:\Acc07_ByExample\images\Square0.gif")
 End Select
End Sub

Public Sub OnGetItemCount(ctl As IRibbonControl, ByRef count)
    count = 12
End Sub

Public Sub OnGetItemLabel(ctl As IRibbonControl, _
                          index As Integer, _
                          ByRef label)
    label = MonthName(index + 1)
    'label = MonthName(index + 1, True)
End Sub

Public Sub OnGetItemImage(ctl As IRibbonControl, _
                          index As Integer, _
                          ByRef image)

  Dim imgPath As String
  
  imgPath = "C:\Acc07_ByExample\images\square"
  Set image = LoadPicture(imgPath & index + 1 & ".gif")
End Sub

Public Sub OpenNotepad(ctl As IRibbonControl)
  Shell "Notepad.exe", vbNormalFocus
End Sub

Public Sub onGetItemID(ctl As IRibbonControl, _
                        index As Integer, ByRef ID)


  ID = MonthName(index + 1)

End Sub

Public Sub onSelectedItem(ctl As IRibbonControl, _
                        SelectedID As String, _
                        SelectedIndex As Integer)
                        
 Select Case SelectedIndex
    Case 6
        MsgBox "Holiday 1: Independence Day, July 4th", _
            vbInformation + vbOKOnly, _
            SelectedID & " Holidays"
            
    Case 11
        MsgBox "Holiday 1: Christmas Day, December 25th", _
            vbInformation + vbOKOnly, _
            SelectedID & " Holidays"
    Case Else
        MsgBox "Please program holidays for " & SelectedID & ".", _
            vbInformation + vbOKOnly, _
            " Under Construction"
   End Select
End Sub


Public Sub OnGetLabel(ctl As IRibbonControl, ByRef label)
  If ctl.ID = "chkSportsMusic" And _
    Weekday(Now(), vbWednesday) Then
    label = "Sports"
  Else
    label = "Music"
  End If
End Sub

Public Sub DoSomething(ctl As IRibbonControl, pressed As Boolean)
 If ctl.ID = "chkSafety" And pressed Then
    MsgBox "Safety is our number one concern."
 Else
    MsgBox "Sorry to hear that safety is not your concern."
 End If
End Sub


Public Sub onFullNameChange(ctl As IRibbonControl, _
                            text As String)
    If text <> "" Then
        MsgBox "Is '" & text & _
        "' your real name?"
    End If
End Sub

Public Sub OnChangeLang(ctl As IRibbonControl, _
                            text As String)

    MsgBox "You selected " & text & " language guide."
End Sub

Public Sub OnActionBoro(ctl As IRibbonControl, _
                        ByRef SelectedID As String, _
                        ByRef SelectedIndex As Integer)

    MsgBox "Index=" & SelectedIndex & " ID=" & SelectedID
   
End Sub

Public Sub OnActionLaunch(ctl As IRibbonControl)
    ' open the About Microsoft Office Access box
    DoCmd.RunCommand acCmdAboutMicrosoftAccess
End Sub


Public Sub DisableRelations(ctl As IRibbonControl, _
                    ByRef cancelDefault)

    MsgBox "You are not authorized to use this function."
    cancelDefault = True
End Sub
                     
                     
Public Sub ShowDbProperties(ctl As IRibbonControl, _
                    ByRef cancelDefault)
    
    If CurrentProject.AllForms("Student List").IsLoaded Then
        ' display Database Properties dialog box instead
        DoCmd.RunCommand acCmdDatabaseProperties
    Else
        cancelDefault = False
    End If
End Sub
                     
                     
Public Sub getEventDate(ctl As IRibbonControl, _
                ByRef ReturnValue As Variant)

  ReturnValue = "Events for " & Format(Now(), "mm/dd/yyyy")
End Sub


Sub onGetBitmap(ctl As IRibbonControl, ByRef image)

    Set image = Application.CommandBars. _
        GetImageMso("CreateReportFromWizard", 16, 16)
End Sub

Sub DoDefaultPlus(ctl As IRibbonControl)
    If Application.CurrentObjectName = "Student List" Then
       Application.CommandBars.ExecuteMso "CreateReportFromWizard"
    Else
       MsgBox "To run this Wizard you need to open " & _
         " the Student List Form", _
         vbOKOnly + vbInformation, "Action Required"
    End If
End Sub



