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!

update mainform from subform query

Status
Not open for further replies.

techkenny1

Technical User
Jan 23, 2009
182
AU
Hi all,

I have been trying to find out how to update the mainform [blue]Totals[/blue] field when you add or change data in a text field in a subform.

The subform (continous) has a subtotals column and there are 3 textfields, the datatype being [blue]Number[/blue] and the fieldsize being [blue]double[/blue]. The subtotals is summed by using code on the [blue]Lost Focus[/blue] event on these fields.

The [blue]Invoice Total[/blue] is on the mainform. The mainform has a refresh command button and this works ok to refresh the data on the mainform.

I have searched the forums to see if the total on the mainform can be automatically updated when the data is changed or added on the subform.
I did find this code;

[blue]Sub myTextbox AfterUpdate()
Form!MasterForm.setfocus
Docmd.Runcommand.accmdrefresh
Form!MasterForm!SubForm.SetFocus
End Sub [/blue]

I changed the names of the main and sub forms, but was not able to get this to refresh the data on the mainform.

Many thanks

kp


__________________




 
You didn't provide any information about how the main form control is supposed to get the information from the subform records.

Why are you using code to sum values? If you are really using code, why didn't you provide it to us?

Values entered into bound controls on a subform aren't saved until the record is saved.

Duane
Hook'D on Access
MS Access MVP
 
Hi dhookom,

Many thanks for your reply. You gave me the answer in your last paragraph..
[blue]Values entered into bound controls on a subform aren't saved until the record is saved[/blue].

So that will answer my query. I will have to make sure that the close button is hidden until the user uses the refresh command button to save the record.

The mainform control [blue]InvoiceTotal[/blue] gets its information from the subform control ie: [blue]=[Accountsdata].[Form]![SubT][/blue]
Perhaps the use of the word "code is incorrrect".

kp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top