[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Fire Tab_Change() upon page clicked after subform is updated

Posted on 2006-05-04
29
Medium Priority
?
303 Views
Last Modified: 2012-06-22
I need to fire the below code when the page is clicked but after several fields which are needed for calculation update with new data pulling from 2 subforms.

 Me.curTotalLayerPremium = Me.calccuml1LayerTotal
    Me.curTotalReinsPremium = 0
    Me.curTotalUmbChargedPremium = Nz(Me.curTotalLayerPremium, 0) + Nz(Me.curTotalReinsPremium, 0)

The problem I'm running into placing this on the tab_chage is that the event fires before me.calccuml1layertotal has a chance to pull the updated values from the 2 subforms.

(Am I making any sense with this?)

As always any help is greatly appreciated.

Rose Marie

0
Comment
Question by:fyrerose
  • 14
  • 13
  • 2
29 Comments
 
LVL 19

Expert Comment

by:Eric Sherman
ID: 16607366
Which version of Access are you using????

ET
0
 

Author Comment

by:fyrerose
ID: 16607382
Access 2002  (soon to be 2003 , hopefully)
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 16607441
Try inserting this code as the first line of the tab control change event:

'commits any changes
If Me.Dirty Then Me.Dirty = False
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Expert Comment

by:Eric Sherman
ID: 16607596
>>>>The problem I'm running into placing this on the tab_chage is that the event fires before me.calccuml1layertotal has a chance to pull the updated values from the 2 subforms.<<<<<<

Try this ...

1.) Update me.calccuml1layertotal based on the OnCurrent Event for your form.

OR

2.) Update me.calccuml1layertotal based on the AfterUpdate Event for your sub-forms.


ET
0
 

Author Comment

by:fyrerose
ID: 16607861
puppydogbuddy,

this is what I have coded so far.

****************

Private Sub tab1_Change()

If Me.Dirty Then Me.Dirty = False

If Me.tab1.Value = 2 Then

Select Case Me.intPolicyLimit

    Case 1
   
    Me.curTotalLayerPremium = Me.calccuml1LayerTotal
    Me.curTotalReinsPremium = 0
    Me.curTotalUmbChargedPremium = Nz(Me.curTotalLayerPremium, 0) + Nz(Me.curTotalReinsPremium, 0)

End Select

End If


End Sub

******************

When I click on page 2 nothing happens, however if I click on any other page and then back on page 2 it fires......
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 16607970
the code I gave you should be in the tab control on the main form, not  on the individual tabs. .the dirty = false statement should commit any unsaved changes from the subforms.

Private Sub TabCtl0_Change()       '<<<<<<<should be for tab control on the main form

If Me.Dirty Then Me.Dirty = False

    Me.curTotalLayerPremium = Me.calccuml1LayerTotal
    Me.curTotalReinsPremium = 0
    Me.curTotalUmbChargedPremium = Nz(Me.curTotalLayerPremium, 0) + Nz(Me.curTotalReinsPremium, 0)



End Sub
0
 

Author Comment

by:fyrerose
ID: 16608011
puppydogbuddy,

That is the tab control, I guess I should've named it something else.  I can see now how misleading the name of it is.
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 16608034
It didn't work????

 try doing a requery just before the end sub

Private Sub TabCtl0_Change()       '<<<<<<<should be for tab control on the main form

If Me.Dirty Then Me.Dirty = False

    Me.curTotalLayerPremium = Me.calccuml1LayerTotal
    Me.curTotalReinsPremium = 0
    Me.curTotalUmbChargedPremium = Nz(Me.curTotalLayerPremium, 0) + Nz(Me.curTotalReinsPremium, 0)

Me.Requery                               '<<<<<<<<<<<<<<<<<<

End Sub
0
 

Author Comment

by:fyrerose
ID: 16608065
That works but it makes the screen flicker when I click on Page 2........  Is there anything I can do about the flicker?
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 16608199
I have never had that problem, but try this  after the requery statement, adapting the code to your actual page numbers/page indexes for the tabcontrol:(I am hoping that the setfocus statement will alleviate the flicker).

Me.Requery
_____________________________Additional code
Select Case Me.TabCtl0.Value
    Case Is = 0   'note Me.Page1.PageIndex = 0
        TabCtl0.Pages.Item(0).SetFocus
    Case Is = 1   'note  Me.Page2.PageIndex = 1
        TabCtl0.Pages.Item(1).SetFocus
    Case Is = 2   'note  Me.Page3.PageIndex = 2
        TabCtl0.Pages.Item(2).SetFocus
End Select

End Sub
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 16608263
could this be the answer to your flickering???  if it is, then you can probably disregard the previous post.

           http://www.allenbrowne.com/ser-46.html
0
 

Author Comment

by:fyrerose
ID: 16608354
I tried using the module and it still flickers.  I've noticed the screen does this whenever I use me.requery.

I added your code also and it still flickers.
0
 

Author Comment

by:fyrerose
ID: 16608360
If I remove me.requery the flickering stops....
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 16608431
ok. maybe we need to requery just the subform control.

instead of me.requery try this using the actual :
me.yoursubformcontrol.requery
me.yoursubformcontrol.requery
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 16608446
oops ! should have been only 1 line for requery of subformcontrol. disregard second line.
0
 

Author Comment

by:fyrerose
ID: 16608534
the main form needs to be requeired not the subform

this is what I need recalculated when the subform changes

Me.curTotalLayerPremium = Me.calccuml1LayerTotal
    Me.curTotalReinsPremium = 0
    Me.curTotalUmbChargedPremium = Nz(Me.curTotalLayerPremium, 0) + Nz(Me.curTotalReinsPremium, 0)
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 16608570
ok, try the following instead of me.requery:

me.recalc    


if me.recalc doesn't work, try this:

me.refresh
0
 

Author Comment

by:fyrerose
ID: 16608651
nope, neither worked
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 16608889
try moving this line:
       If Me.Dirty Then Me.Dirty = False

to the line before Me.Requery, and comment out me.requery, then try it.

if doing that does not update the computation, uncomment me.requery and then try it.
0
 

Author Comment

by:fyrerose
ID: 16609544
That doesn't help either.  I noticed the form also flickers when moving from one record to the next.  
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 16609757
OK, lets try another approach....turn screen painting off and on.  

Me.Requery
_____________________________Additional code

Me.Painting = False      'turn off screen painting until subform has focus
Select Case Me.TabCtl0.Value
    Case Is = 0   'note Me.Page1.PageIndex = 0
        TabCtl0.Pages.Item(0).SetFocus
    Case Is = 1   'note  Me.Page2.PageIndex = 1
        TabCtl0.Pages.Item(1).SetFocus
    Case Is = 2   'note  Me.Page3.PageIndex = 2
        TabCtl0.Pages.Item(2).SetFocus
End Select
Me.Painting = True
0
 

Author Comment

by:fyrerose
ID: 16609804
nope still flickering..... grrrr
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 16610142
LOL.....ooh sooooo frustrating!!!....
on the basis of what Access help says about repainting, I think we need to apply it to each of the subforms, so let's comment out the setfocus on the tab control and try to setfocus on the subform:

Me.Painting = False      'turn off screen painting until subform has focus
Select Case Me.TabCtl0.Value
    Case Is = 0   'note Me.Page1.PageIndex = 0
    '    TabCtl0.Pages.Item(0).SetFocus
         Me.YourSubform1.SetFocus    
Case Is = 1   'note  Me.Page2.PageIndex = 1
    '    TabCtl0.Pages.Item(1).SetFocus
         Me.YourSubform2.SetFocus
    End Select
Me.Painting = True


_______________________________From Access Help____________________________
Setting the Painting property for a form or report to False also prevents all controls (except subform or subreport controls) on a form or report from being repainted. To prevent a subform or subreport control from being repainted, you must set the Painting property for the subform or subreport to False. (Note that you set the Painting property for the subform or subreport, not the subform or subreport control.)

The Painting property is automatically set to True whenever the form or report gets or loses the focus. You can set this property to False while you are working on a form or report if you don't want to see changes to the form or report or to its controls. For example, if a form has a set of controls that are automatically resized when the form is resized and you don't want the user to see each individual control move, you can turn Painting off, and then move all of the controls, then turn Painting back on.

 
0
 

Author Comment

by:fyrerose
ID: 16610195
puppydogbuddy,

It's not the subforms per se that are flickering, it's the tab control.  Everything above the tab control does not flicker.  Everything on the tab control, whether it's a subform or regular text controls, flicker.
0
 
LVL 38

Accepted Solution

by:
puppydogbuddy earned 500 total points
ID: 16610259
that is why I want to turn painting off until subform has focus...hopefully flickering before focus occurs will be gone.
0
 

Author Comment

by:fyrerose
ID: 16610291
I don't quite understand why you're trying to keep the subform on page 0 from flickering when the code is firing when I click on page 2 which has no subforms?a
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 16610379
keep in mind that I don't know what you have on each page or how you have indexed them...that is why I've been telling that you have to adjust my code to your specifics.  In your case, if clicking on page 2 is flickering than modify the code I gave you so that it incorporates the pages that are flickering.
0
 

Author Comment

by:fyrerose
ID: 16610390
puppydogbuddy,

Your approach gave me an idea.  This is what I'm using now.

Private Sub tab1_Change()

If Me.Dirty Then Me.Dirty = False

    If Me.tab1.Value = 2 Then
   
    Me.Painting = False

        intPolicyLimit_AfterUpdate

    Me.Requery

    Me.Painting = True

    End If

End Sub

NO FLICKER!!

yay!

Thanks so much for your help.

Rose Marie
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 16610431
Wow!! way to go! Thank you.
0

Featured Post

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question