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

How to loop thru subform data

Status
Not open for further replies.

teriwinkle

Technical User
Oct 29, 2003
7
US
I have a main form: JobInput2, and a subform: PartNumbers.

On this main form linked by a field named [JobNo]. I want to be able to check each PartNo record on the subform to see if the field [NveRequired] is checked true. If it is true, then I want the [NvrNo] generated on the main form to be transfered to the the [NvrNumber] on the subform. I used the following code, but it transferred it to the first PartNo only.

If Forms![JobInput2]![PartNumbers].Form![NvrRequired]= true Then

Forms![JobInput2]![PartNumbers].Form![NvrNumber] = Me!NvrNo.Value


However, it only applies to the first [PartNo] record regardless of the [NvrRequired] value.

How can I check for the [NvrRequired] value on the subform to be true, and if it is, apply the [NvrNo] field from the main form to the [NvrNumber] field on the subform, for each of the subforms [PartNo] records?

Thanks for your help!!
 
You may try something like this either in the Current event procedure of the main form or the AfterUpdate procedure of the NvrNo control, depending on how NvrNo is generated:
DoCmd.RunSQL "UPDATE PartNumbersTable SET NvrNumber=" & Me!NvrNo & " WHERE NvrRequired=True AND JobNo=" & Me!JobNo & ";"
Forms!JobInput2!PartNumbers.Requery


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top