Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter and Header Updates

Status
Not open for further replies.

EdwardSalas

Technical User
Oct 20, 2004
8
US
Afternoon all,

I've got an interesting one here...I've got a form that is tied to query (very simple). On the header portion of the form I have a calculated field that sums one of the fields.

Here is the problem

I want to apply a filter and determine a % share (Sum of Calc Field filtered / Sum of Total unfiltered) on a click of a command button. The command button applies a filter and writes the 'Sum of Total Unfiltered' into a temp field. However, the code runs so quick that there is no value in the 'Sum of Calc Field' because Access is trying to perform the calculation. I've tried Requerying and that also doesn't work. I'm tempted to use a loop but I don't care to be locked into a timed event (because some categories are larger than others, it may need a longer processing time).

any help would be appreciated!

Eddy
 
How are ya EdwardSalas . . .

[ol][li]Set a Private variable in the decalarations section of the forms code module:
Code:
[blue]Private SOTU As Single [green]'SumOfTotalUnfiltered[/green][/blue]
[/li]
[li]In the OnLoad event og the form, copy/paste the following:
Code:
[blue]   SOTU = Me![[purple][b]TextboxName[/b][/purple] for SumofCalcFieldFiltered][/blue]
Now your total is saved and SOTU remains as long as the form is open.[/li]
[li]Setup your [blue]TempField[/blue] to display the results by adjusting the following properties:
[ol a][li]Remove any text in the ControlSource[/li]
[li]Set the Format to Percent.[/li][/ol][/li]
[li]Finally, change your button code to:
Code:
[blue]   Me.Filter = [green]'Your Filter[/green]
   Me.FilterOn = True
   Me!TempFieldName = Me![[purple][b]TextboxName[/b][/purple] for SumofCalcFieldFiltered]/SOTU[/blue]
[/li][/ol]
Check it out!

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top