splats
Technical User
- Jan 2, 2003
- 131
Hello
I have a Main form (frmApplicantCostsCombo) that I would like to autopopulate a subform (sfrmPayment)based on fields from the Main Form. It is working except that it only puts out one record. I would like it to put in as many records as there are stated in the Disburse field (that says how many disbursements are given out).
As well, another problem that is happening is that the subform is not requerying after this event takes place. I would like to see the resulting new records in the subform as soon as the command button is pushed.
Any suggestions would be greatly appreciated. Below is my code for the Command button on the main form.
Thank you
Private Sub cmdDisbursement_Click()
On Error GoTo Err_cmdDisbursement_Click
Dim rst As DAO.Recordset
Dim i, DNumber As Integer
Dim Amount As Currency
Dim Appl As Integer
DNumber = Me.Disburse '- a control on the form
Amount = Me.AmtDisburse '- a control on the form
Appl = Me.ApplID
Set rst = CurrentDb.OpenRecordset("tblDisburse", dbOpenTable)
'Set rst = CurrentDb.OpenRecordset("Table1", dbOpenTable)
For i = 0 To i = DNumber - 1
rst.AddNew
rst!DisburseAmt = Amount
rst!ApplID = Appl
rst.Update
Next i
rst.Close
Set rst = Nothing
'Requery subform that new records are listing
sfrmPayment.Requery
Exit_cmdDisbursement_Click:
Exit Sub
Err_cmdDisbursement_Click:
MsgBox Err.Description
Resume Exit_cmdDisbursement_Click
End Sub
I have a Main form (frmApplicantCostsCombo) that I would like to autopopulate a subform (sfrmPayment)based on fields from the Main Form. It is working except that it only puts out one record. I would like it to put in as many records as there are stated in the Disburse field (that says how many disbursements are given out).
As well, another problem that is happening is that the subform is not requerying after this event takes place. I would like to see the resulting new records in the subform as soon as the command button is pushed.
Any suggestions would be greatly appreciated. Below is my code for the Command button on the main form.
Thank you
Private Sub cmdDisbursement_Click()
On Error GoTo Err_cmdDisbursement_Click
Dim rst As DAO.Recordset
Dim i, DNumber As Integer
Dim Amount As Currency
Dim Appl As Integer
DNumber = Me.Disburse '- a control on the form
Amount = Me.AmtDisburse '- a control on the form
Appl = Me.ApplID
Set rst = CurrentDb.OpenRecordset("tblDisburse", dbOpenTable)
'Set rst = CurrentDb.OpenRecordset("Table1", dbOpenTable)
For i = 0 To i = DNumber - 1
rst.AddNew
rst!DisburseAmt = Amount
rst!ApplID = Appl
rst.Update
Next i
rst.Close
Set rst = Nothing
'Requery subform that new records are listing
sfrmPayment.Requery
Exit_cmdDisbursement_Click:
Exit Sub
Err_cmdDisbursement_Click:
MsgBox Err.Description
Resume Exit_cmdDisbursement_Click
End Sub