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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update field on main form from field on subform issue

Status
Not open for further replies.

tizwaz

Technical User
Aug 8, 2002
437
GB
Hi there

I need to update a field on my main form using the value of a field on my sub-form. I have created a text box on the subform called txtcountitems which counts the item_id field of that form. This seems to work ok. However I have tried putting the following code on the after update (also tried after insert) event of the subform but it seems to partly work in that it is always 1 record behind the correct one. ie I add the first record to the subform and the field on the main form remains as 0 - I add the 2nd record and it goes to 1. Can anyone advise what I am doing wrong?

If CurrentProject.AllForms("frmIncidentNew").IsLoaded = True Then
Forms!frmIncidentNew!txtItemCount.Value = Me.Txtcountitems.Value

ElseIf CurrentProject.AllForms("frmIncidentDetails").IsLoaded = True Then
Forms!frmIncidentdetails!txtItemCount.Value = Me.Txtcountitems.Value
End If
 
I'd use the Current event procedure of the subform.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
thanks but that seems to create an error when I open the form frmIncidentsNew (probably because it is at that stage a form with no data) - error is that a value cannot be assigned to this object
 
Sorry to seem over simplistic but why not just add 1 to the value when updating in the after update event?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top