am trying to get my nav buttons up to date every time I move to another record, my XML file is good and my call back related to them are also good.
The problem is when I load my main form, I get an error91 object variable or with block not set. I tried to create a small sub to specially invalidate specific controls but it works only when my main form is loaded again.
So I want to know on how I can solve this, here is what I did so far:
<customUI xmlns="http://schemas.microso ft.com/office/2006/01/customui" onLoad="OnLoadR ibbon">
<ribbon startFromScratc h="true">
<tabs>
<tab id="tabHome" label="Home">
<group id="grpNews" label="News">
<labelControl id="lblWelcome " getLabel="onGet Label"/>
<labelControl id="lblToday" getLabel="onGet Label"/>
</group>
<group id="gprTools" label="Tools">
<button idMso="Spelling Access" label="Spelling " size="large"/>
<button idMso="FindDial og" label="Find" size="large"/>
<toggleButton idMso="FiltersM enu" label="Filter" size="large"/>
</group>
<group id="grpNav" label="Navigati on">
<box id="boxNavLbl" boxStyle="horiz ontal">
<labelControl id="lblNav" getLabel="OnGet Label"/>
</box>
<box id="boxNav" boxStyle="horiz ontal">
<buttonGroup id="bg1">
<button id="NewLease" imageMso="GoToN ewRecord" onAction="OnNav igateRecord" getEnabled="OnG etNavEnabled"/>
<button id="MoveFirst" imageMso="MailM ergeGoToFirstRe cord" onAction="OnNav igateRecord" getEnabled="OnG etNavEnabled"/>
<button id="MovePrev" imageMso="MailM ergeGoToPreviou sRecord" onAction="OnNav igateRecord" getEnabled="OnG etNavEnabled"/>
</buttonGroup>
<editBox id="txtJump" sizeString="000 000" onChange="OnCha ngeRecord" getText="OnGetT ext"/>
<buttonGroup id="bg2">
<button id="MoveNext" imageMso="MailM ergeGoToNextRec ord" onAction="OnNav igateRecord" getEnabled="OnG etNavEnabled"/>
<button id="MoveLast" imageMso="MailM ergeGotToLastRe cord" onAction="OnNav igateRecord" getEnabled="OnG etNavEnabled"/>
<button id="DelLease" imageMso="Recor dsDeleteRecord" onAction="OnNav igateRecord" getEnabled="OnG etNavEnabled"/>
</buttonGroup>
</box>
</group>
<group id="grpExit" label="Exit">
<button id="cmdCloseDat abase" label="Close Database" imageMso="FileC lose" size="large" onAction="onBut tonCommand" supertip="Close current database only."/>
<button id="cmdExitData base" label="Close And Exit" imageMso="Print PreviewClose" size="large" onAction="onBut tonCommand" supertip="Exit the database and close Access."/>
</group>
<group id="grpAbout" label="About">
<button id="cmdHelpAbou t" label="About" size="large" imageMso="Help" onAction="onOpe nFormEdit" tag="frmAbout" supertip="View the About form."/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
my module where I keep callbacks
Public gobjRibbon As IRibbonUI
Public Sub OnLoadRibbon(ob jRibbon As IRibbonUI)
Set gobjRibbon = objRibbon
'to refresh, or invalidate all controls in the Ribbon
If (Not gobjRibbon Is Nothing) Then
gobjRibbon.Inva lidate
End If
End Sub
Public Sub OnNavigateRecor d(ctl As IRibbonControl)
'to allow user to navigate thru records
Dim rec As AcRecord
Select Case ctl.ID
Case "MoveFirst"
rec = acFirst
Case "MovePrev"
rec = acPrevious
Case "MoveNext"
rec = acNext
Case "MoveLast"
rec = acLast
End Select
DoCmd.GoToRecor d , , rec
If (Not gobjRibbon Is Nothing) Then
' invalidate the nav label
gobjRibbon.Inva lidateControl "lblNav"
End If
End Sub
And my main form current event:
Private Sub Form_Current()
On Error GoTo ErrorHandler_Er ror
'invalidate controls to keep in sync with record movement
gobjRibbon.Inva lidateControl "lblNav"
gobjRibbon.Inva lidateControl "MoveFirst"
gobjRibbon.Inva lidateControl "MovePrev"
gobjRibbon.Inva lidateControl "MoveNext"
gobjRibbon.Inva lidateControl "MoveLast"
............... ..........
............... .........
End sub
I also tried calling my invalidate thru a custom function but still get the same result.
I understang that my gobjRibbon is declared as a global variable, my other callbalck that require gobjRibbon are all working just fine, I do not need to declare it again
but when it come to my main form, I get an error
Any help is greatly appreciated since I have been on that problem for the past 2 days
Thanks
The problem is when I load my main form, I get an error91 object variable or with block not set. I tried to create a small sub to specially invalidate specific controls but it works only when my main form is loaded again.
So I want to know on how I can solve this, here is what I did so far:
<customUI xmlns="http://schemas.microso ft.com/office/2006/01/customui" onLoad="OnLoadR ibbon">
<ribbon startFromScratc h="true">
<tabs>
<tab id="tabHome" label="Home">
<group id="grpNews" label="News">
<labelControl id="lblWelcome " getLabel="onGet Label"/>
<labelControl id="lblToday" getLabel="onGet Label"/>
</group>
<group id="gprTools" label="Tools">
<button idMso="Spelling Access" label="Spelling " size="large"/>
<button idMso="FindDial og" label="Find" size="large"/>
<toggleButton idMso="FiltersM enu" label="Filter" size="large"/>
</group>
<group id="grpNav" label="Navigati on">
<box id="boxNavLbl" boxStyle="horiz ontal">
<labelControl id="lblNav" getLabel="OnGet Label"/>
</box>
<box id="boxNav" boxStyle="horiz ontal">
<buttonGroup id="bg1">
<button id="NewLease" imageMso="GoToN ewRecord" onAction="OnNav igateRecord" getEnabled="OnG etNavEnabled"/>
<button id="MoveFirst" imageMso="MailM ergeGoToFirstRe cord" onAction="OnNav igateRecord" getEnabled="OnG etNavEnabled"/>
<button id="MovePrev" imageMso="MailM ergeGoToPreviou sRecord" onAction="OnNav igateRecord" getEnabled="OnG etNavEnabled"/>
</buttonGroup>
<editBox id="txtJump" sizeString="000 000" onChange="OnCha ngeRecord" getText="OnGetT ext"/>
<buttonGroup id="bg2">
<button id="MoveNext" imageMso="MailM ergeGoToNextRec ord" onAction="OnNav igateRecord" getEnabled="OnG etNavEnabled"/>
<button id="MoveLast" imageMso="MailM ergeGotToLastRe cord" onAction="OnNav igateRecord" getEnabled="OnG etNavEnabled"/>
<button id="DelLease" imageMso="Recor dsDeleteRecord" onAction="OnNav igateRecord" getEnabled="OnG etNavEnabled"/>
</buttonGroup>
</box>
</group>
<group id="grpExit" label="Exit">
<button id="cmdCloseDat abase" label="Close Database" imageMso="FileC lose" size="large" onAction="onBut tonCommand" supertip="Close current database only."/>
<button id="cmdExitData base" label="Close And Exit" imageMso="Print PreviewClose" size="large" onAction="onBut tonCommand" supertip="Exit the database and close Access."/>
</group>
<group id="grpAbout" label="About">
<button id="cmdHelpAbou t" label="About" size="large" imageMso="Help" onAction="onOpe nFormEdit" tag="frmAbout" supertip="View the About form."/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
my module where I keep callbacks
Public gobjRibbon As IRibbonUI
Public Sub OnLoadRibbon(ob jRibbon As IRibbonUI)
Set gobjRibbon = objRibbon
'to refresh, or invalidate all controls in the Ribbon
If (Not gobjRibbon Is Nothing) Then
gobjRibbon.Inva lidate
End If
End Sub
Public Sub OnNavigateRecor d(ctl As IRibbonControl)
'to allow user to navigate thru records
Dim rec As AcRecord
Select Case ctl.ID
Case "MoveFirst"
rec = acFirst
Case "MovePrev"
rec = acPrevious
Case "MoveNext"
rec = acNext
Case "MoveLast"
rec = acLast
End Select
DoCmd.GoToRecor d , , rec
If (Not gobjRibbon Is Nothing) Then
' invalidate the nav label
gobjRibbon.Inva lidateControl "lblNav"
End If
End Sub
And my main form current event:
Private Sub Form_Current()
On Error GoTo ErrorHandler_Er ror
'invalidate controls to keep in sync with record movement
gobjRibbon.Inva lidateControl "lblNav"
gobjRibbon.Inva lidateControl "MoveFirst"
gobjRibbon.Inva lidateControl "MovePrev"
gobjRibbon.Inva lidateControl "MoveNext"
gobjRibbon.Inva lidateControl "MoveLast"
............... ..........
............... .........
End sub
I also tried calling my invalidate thru a custom function but still get the same result.
I understang that my gobjRibbon is declared as a global variable, my other callbalck that require gobjRibbon are all working just fine, I do not need to declare it again
but when it come to my main form, I get an error
Any help is greatly appreciated since I have been on that problem for the past 2 days
Thanks
Comment