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: 351
  • err.GIF
    err.GIF
    8 KB · Views: 235
Last edited:
Joined
Feb 14, 2012
Messages
2
Reaction score
0
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top