Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 28th, 2005, 02:13 PM
ru1 ru1 is offline
Authorized User
 
Join Date: Feb 2005
Location: Detroit, MI, USA.
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default Event procedures Primary Form

Hi everyone. I have this STRONG RUNNING database where on a primary form I have totals that come from summing up the information on a subform. For instance, If a judge has 12 cases on his docket with a total of say 30 plaintiffs and 12 defendents, I show the respective totals. But, if I add a plaintiff to one of the cases, the numbers on the primary form does not refresh.

In moving from a subform to a primary form, which event procedure do I need to use to refresh my totals. Better yet, is there a way on the subform to refresh the totals on the primary form after the number has been changed on the subform?

Any help would be highly appreciated.

Thanks,

Ru1

Reply With Quote
  #2 (permalink)  
Old February 28th, 2005, 02:30 PM
Friend of Wrox
 
Join Date: Jan 2005
Location: Kansas City, Missouri, USA.
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

On your subform, when you change or add, try using the "after update" event procedure.
whatever field needs to be updated,

Mainform.field.requery

Hope it helps



dartcoach
Reply With Quote
  #3 (permalink)  
Old February 28th, 2005, 02:51 PM
ru1 ru1 is offline
Authorized User
 
Join Date: Feb 2005
Location: Detroit, MI, USA.
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the suggestion, but that sill doesn't help. I need to run the code that builds the totals. Any other thoughts?

RU1


Reply With Quote
  #4 (permalink)  
Old February 28th, 2005, 02:54 PM
Friend of Wrox
 
Join Date: Jan 2005
Location: Kansas City, Missouri, USA.
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Where is the code? Is it in a module?

dartcoach
Reply With Quote
  #5 (permalink)  
Old February 28th, 2005, 02:59 PM
ru1 ru1 is offline
Authorized User
 
Join Date: Feb 2005
Location: Detroit, MI, USA.
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes. It is in a module.

Reply With Quote
  #6 (permalink)  
Old February 28th, 2005, 03:01 PM
Friend of Wrox
 
Join Date: Jan 2005
Location: Kansas City, Missouri, USA.
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

can you call the module from the after update procedure?

dartcoach
Reply With Quote
  #7 (permalink)  
Old February 28th, 2005, 03:05 PM
ru1 ru1 is offline
Authorized User
 
Join Date: Feb 2005
Location: Detroit, MI, USA.
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No. It is in the current event procedure of the primary form.

Reply With Quote
  #8 (permalink)  
Old March 4th, 2005, 10:22 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Seattle, WA, .
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

Well actually, yes you can call the Form_Current of the main form. However, you need to change from "Private Sub Form_Current" to "Public Sub Form_Current". Beware, that can make things very confusing, especially if you try to do that with more than one form...

A better way to do this is to create a "Public Sub UpdateTotals" procedure in the main form, or any module (which is what dartcoach was really asking), and have the Form_Current of your main form call that. Other modules and forms can call it too. If you create the UpdateTotals in something other than your main form the procedure won't have a context for the fields of your main form which means you'll have to use specific reference to the form to update the fields (e.g. Forms("main_formname").field_name). So the best bet is to have that procedure in your main form.

Also, watch out for that Current event, especially in your child forms! It runs for so many different reasons... often multiple times.

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
Reply With Quote
  #9 (permalink)  
Old March 7th, 2005, 03:58 PM
ru1 ru1 is offline
Authorized User
 
Join Date: Feb 2005
Location: Detroit, MI, USA.
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by rjweers
 Well actually, yes you can call the Form_Current of the main form. However, you need to change from "Private Sub Form_Current" to "Public Sub Form_Current". Beware, that can make things very confusing, especially if you try to do that with more than one form...

A better way to do this is to create a "Public Sub UpdateTotals" procedure in the main form, or any module (which is what dartcoach was really asking), and have the Form_Current of your main form call that. Other modules and forms can call it too. If you create the UpdateTotals in something other than your main form the procedure won't have a context for the fields of your main form which means you'll have to use specific reference to the form to update the fields (e.g. Forms("main_formname").field_name). So the best bet is to have that procedure in your main form.

Also, watch out for that Current event, especially in your child forms! It runs for so many different reasons... often multiple times.

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access project using event procedures luissilva755 Access VBA 1 October 29th, 2008 07:33 AM
HELP ME! Project with event procedures luissilva755 Access VBA 1 October 29th, 2008 07:29 AM
Form Event Procedure Help dbartelt Access 2 June 7th, 2005 04:10 PM
Overriding Form Close event Chris Beach C# 1 January 16th, 2005 10:20 AM
How to use KeyDown event in Form zhangxujun1981 C# 5 July 6th, 2004 02:07 AM



All times are GMT -4. The time now is 09:11 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.