 |
| 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
|
|
|
|

April 27th, 2005, 01:25 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
|
|
updating main form from subform
Hi All!
Been gone awhile!
I have a mainform - treatment
I have a subform - payment history
payment history is a continuous form
I keep the starting balance and balance due on the mainform
I want to update the balance due after I have entered an amount in the payment history subform - without leaving the subform.
Can anyone help!
Thanks,
Dartcoach
kevin
dartcoach
__________________
dartcoach
|
|

April 27th, 2005, 01:44 PM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
Hi,
Without knowing where you are getting the data on your main form, can't you requery the control on the main form when the pertinent field on the sub form loses focus?
mmcdonal
|
|

April 27th, 2005, 01:51 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
|
|
The main form gets it's data from a table.
The sub form connects based on ID's.
Once I've entered a payment amount - I need to total all payments on the subform, then update the balance due on the main form. I've tried to refresh, requery, just about anything, but it won't refresh until I close the mainform and reopen it.
Thanks for your help.
dartcoach
Kevin
dartcoach
|
|

April 27th, 2005, 02:12 PM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
Well, as a quick kludge, you can put code on the lost focus event of the pertinent field to grab the current main form id, then close the main form and reopen it using the current main form id to get the right record.
Someone here will come up with something more elegant shortly I am sure.
mmcdonal
|
|

April 27th, 2005, 03:40 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hey All!
Got it to work!
Basically, all I did was after they enter a payment amount, I use the current record number, then make the subform invisible, then go to the first record, then loop thru adding the amounts until the end. Then I reposition at the correct record and then make the subform visible again. This cause a blink, but it's better than watching the loop thru the form records.
MMCDonal, thanks for your help! Also, if anyone has a better idea, I'll be glad to hear it!
Thanks again!
Dartcoach
Kevin
dartcoach
|
|

April 28th, 2005, 08:02 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
|
|
If you want to stop the blink (which I assume is the subform closing), you could
DoCmd.Echo False
before your code hides the subform, and
DoCmd.Echo True
after you code unhides the subform.
|
|

April 28th, 2005, 08:27 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Thanks Randall,
I added the code you suggested. I still get the blink. Being an old mainframe cobol programmer, the blink doesn't bother me too much, even though I would like to get rid of it.
Thanks for your help!
Dartcoach
Kevin
dartcoach
|
|
 |