473,412 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Problem with invalidateControls

2
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.microsoft.com/office/2006/01/customui" onLoad="OnLoadRibbon">
<ribbon startFromScratch="true">
<tabs>
<tab id="tabHome" label="Home">

<group id="grpNews" label="News">
<labelControl id="lblWelcome" getLabel="onGetLabel"/>
<labelControl id="lblToday" getLabel="onGetLabel"/>
</group>

<group id="gprTools" label="Tools">
<button idMso="SpellingAccess" label="Spelling" size="large"/>
<button idMso="FindDialog" label="Find" size="large"/>
<toggleButton idMso="FiltersMenu" label="Filter" size="large"/>
</group>

<group id="grpNav" label="Navigation">
<box id="boxNavLbl" boxStyle="horizontal">
<labelControl id="lblNav" getLabel="OnGetLabel"/>
</box>
<box id="boxNav" boxStyle="horizontal">
<buttonGroup id="bg1">
<button id="NewLease" imageMso="GoToNewRecord" onAction="OnNavigateRecord" getEnabled="OnGetNavEnabled"/>
<button id="MoveFirst" imageMso="MailMergeGoToFirstRecord" onAction="OnNavigateRecord" getEnabled="OnGetNavEnabled"/>
<button id="MovePrev" imageMso="MailMergeGoToPreviousRecord" onAction="OnNavigateRecord" getEnabled="OnGetNavEnabled"/>
</buttonGroup>
<editBox id="txtJump" sizeString="000000" onChange="OnChangeRecord" getText="OnGetText"/>
<buttonGroup id="bg2">
<button id="MoveNext" imageMso="MailMergeGoToNextRecord" onAction="OnNavigateRecord" getEnabled="OnGetNavEnabled"/>
<button id="MoveLast" imageMso="MailMergeGotToLastRecord" onAction="OnNavigateRecord" getEnabled="OnGetNavEnabled"/>
<button id="DelLease" imageMso="RecordsDeleteRecord" onAction="OnNavigateRecord" getEnabled="OnGetNavEnabled"/>
</buttonGroup>
</box>
</group>

<group id="grpExit" label="Exit">
<button id="cmdCloseDatabase" label="Close Database" imageMso="FileClose" size="large" onAction="onButtonCommand" supertip="Close current database only."/>
<button id="cmdExitDatabase" label="Close And Exit" imageMso="PrintPreviewClose" size="large" onAction="onButtonCommand" supertip="Exit the database and close Access."/>
</group>

<group id="grpAbout" label="About">
<button id="cmdHelpAbout" label="About" size="large" imageMso="Help" onAction="onOpenFormEdit" 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(objRibbon As IRibbonUI)
Set gobjRibbon = objRibbon

'to refresh, or invalidate all controls in the Ribbon
If (Not gobjRibbon Is Nothing) Then
gobjRibbon.Invalidate
End If
End Sub

Public Sub OnNavigateRecord(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.GoToRecord , , rec

If (Not gobjRibbon Is Nothing) Then
' invalidate the nav label
gobjRibbon.InvalidateControl "lblNav"
End If
End Sub

And my main form current event:
Private Sub Form_Current()
On Error GoTo ErrorHandler_Error

'invalidate controls to keep in sync with record movement
gobjRibbon.InvalidateControl "lblNav"
gobjRibbon.InvalidateControl "MoveFirst"
gobjRibbon.InvalidateControl "MovePrev"
gobjRibbon.InvalidateControl "MoveNext"
gobjRibbon.InvalidateControl "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
Jun 22 '10 #1
2 5323
jimatqsi
1,271 Expert 1GB
Give us the big picture. What do you mean, "my main form"? What is the main form, what is the subform, how are they interacting together?

You said "but it works only when my main form is loaded again." so I'm wondering, is the main form being closed at some point?

Also, please use code tags. You do that by clicking the "#" button before you start typing code, or type your code, then highlight it, and the click the "#" button.

Jim
Jun 23 '10 #2
alainb
2
My main forms is form being loaded at first, this form has only 1 subform attached to it(only 7 text field on it, linked as master/chield), all other forms are being opened as popups from command button so the information displayed is related to the curernt record on the main form. I only use 1 ribbon for all of my forms, right now, the popups do not display any ribbons at all because I do not need them, they are just data entry forms.
The main forms is never being close unless you want to go to another section of the program like financials or reports, accessible from the switchboard.

My entire process goes like this:
once the ribbon vartiable is loaded, it call the onGetLabels to populate 3 text field on the first group, all OK, then it call onGetNavEnable to peoperly set my nav bottons in a separate group, then call the onGetLabel to populate the text field with the qty of current filtered record, then the main forms current event kicks in and the error is displayed. I do have a function being called from the current event of the main form to update the nav controls when moving to another record.
Unless I am mistaken about the process of ribbon loading, that is the way it goes.

This is the first time I use this site so I am not sure by waht you mean by using code tags, is it when I post code here so it can be clearer ?

Many Thanks
Al
Jun 23 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition when a child thread pops up a Pmw dialog window in...
11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
117
by: Peter Olcott | last post by:
www.halting-problem.com
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
9
by: AceKnocks | last post by:
I am working on a framework design problem in which I have to design a C++ based framework capable of solving three puzzles for now but actually it should work with a general puzzle of any kind and I...
1
by: balaji04 | last post by:
Hi, I've a problem with exporting my query results into excel. When the rows returned are less, export to excel is happening without any issues. When there is large number of rows, IE is showing...
1
by: kondi69 | last post by:
Hello, I'm right newbe in c# but I have big problem with passing data between forms. Below code: : public Form1 main = new Form1(); public int opuwminuty;
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.