looping through a continuous form recordset

Joined
Feb 14, 2012
Messages
2
Reaction score
0
Hi there,
For some time now I'm having the following problem.
I have a main form with contionuous subform (pic1.png). What i want to do is when I change the value of a combobox in the main for to be able to change one of subforms's textboxes. My problem is that I only get the first row to change. I get the folowing error --> shown on err.png
So is there a way to change them all?

Here's my code. I call the function in the combobox's AfterUpdate event:

Code:
Private Sub calculateWeight()
    Me!frmCalculatorDetails.Form!art_id.SetFocus
    Me!frmCalculatorDetails.Form!art_qty_scrap.Value = Me!frmCalculatorDetails.Form!art_weight_net.Value * Me.calc_scrap_nonscrap.Value
    Me!frmCalculatorDetails.Form!art_weight_gross.Value = Me!frmCalculatorDetails.Form!art_weight_net.Value + Me!frmCalculatorDetails.Form!art_qty_scrap.Value

    With Me!frmCalculatorDetails.Form!RecordsetClone
        While Not .EOF
            Me!frmCalculatorDetails.Form!art_qty_scrap.Value = Me!frmCalculatorDetails.Form!art_weight_net.Value * Me.calc_scrap_nonscrap.Value
            Me!frmCalculatorDetails.Form!art_weight_gross.Value = Me!frmCalculatorDetails.Form!art_weight_net.Value + Me!frmCalculatorDetails.Form!art_qty_scrap.Value
            If Not .EOF Then .MoveNext
        Wend
    End With
    
End Sub
 

Attachments

  • pic1.GIF
    pic1.GIF
    58.9 KB · Views: 359
  • err.GIF
    err.GIF
    8 KB · Views: 241
Last edited:
I made the following changes to the code, but now it only updates the selected record:

Code:
Private Sub calculateWeight()
    Me!frmCalculatorDetails.Form!art_id.SetFocus
    Me!frmCalculatorDetails.Form!art_qty_scrap.Value = Me!frmCalculatorDetails.Form!art_weight_net.Value * Me.calc_scrap_nonscrap.Value
    Me!frmCalculatorDetails.Form!art_weight_gross.Value = Me!frmCalculatorDetails.Form!art_weight_net.Value + Me!frmCalculatorDetails.Form!art_qty_scrap.Value

    With Me.frmCalculatorDetails.Form.RecordsetClone
        While Not .EOF
            Me.frmCalculatorDetails.Form.art_qty_scrap.Value = Me.frmCalculatorDetails.Form.art_weight_net.Value * Me.calc_scrap_nonscrap.Value
            Me.frmCalculatorDetails.Form.art_weight_gross.Value = Me.frmCalculatorDetails.Form.art_weight_net.Value + Me.frmCalculatorDetails.Form.art_qty_scrap.Value
            If Not .EOF Then .MoveNext
        Wend
    End With
    
End Sub
 
Back
Top