pokeymonsc
Technical User
I have a parent form linked to a multirecord unbound subform.
I am using the following code to load the subform:
Dim rs As DAO.Recordset
Dim QDef As QueryDef
Dim tmpID As Integer
tmpID = Forms!SalaryBenefits!txtEmpID.Value
Set QDef = CurrentDb.CreateQueryDef("", "select * from dbo_payperiodcharges where empid = " & tmpID & " and payperiod between #01/01/2004# and #3/30/2004#")
Set rs = QDef.OpenRecordset
counter = rs.RecordCount
If counter > 0 Then
Do Until rs.EOF
Me.PayPeriod = rs.Fields![PayPeriod]
Me.HoursWorked = rs.Fields![HoursWorked]
Me.HourrsInvoiced = rs.Fields![HourrsInvoiced]
Me.ChargeDebit = rs.Fields![ChargeDebit]
Me.ChargeCredit = rs.Fields![ChargeCredit]
Me.ChargeOther = rs.Fields![ChargeOther]
Me.Balance = rs.Fields![Balance]
Me.Comments = rs.Fields![Comments]
Me.Check22 = rs.Fields![Verified]
Me.RecordID = rs.Fields![RecordID]
Me.EmpID = rs.Fields![EmpID]
rs.MoveNext
Loop
End If
Stepping through the code I get 13 subform records for the first EmpID (which is the correct #) But --- and here's my problem: On the form itself I have displayed the last record 13 times, not 13 records 1 time each. It's almost as if I need to have a me.movenext but there isn't any. Any suggestions out there?
I am using the following code to load the subform:
Dim rs As DAO.Recordset
Dim QDef As QueryDef
Dim tmpID As Integer
tmpID = Forms!SalaryBenefits!txtEmpID.Value
Set QDef = CurrentDb.CreateQueryDef("", "select * from dbo_payperiodcharges where empid = " & tmpID & " and payperiod between #01/01/2004# and #3/30/2004#")
Set rs = QDef.OpenRecordset
counter = rs.RecordCount
If counter > 0 Then
Do Until rs.EOF
Me.PayPeriod = rs.Fields![PayPeriod]
Me.HoursWorked = rs.Fields![HoursWorked]
Me.HourrsInvoiced = rs.Fields![HourrsInvoiced]
Me.ChargeDebit = rs.Fields![ChargeDebit]
Me.ChargeCredit = rs.Fields![ChargeCredit]
Me.ChargeOther = rs.Fields![ChargeOther]
Me.Balance = rs.Fields![Balance]
Me.Comments = rs.Fields![Comments]
Me.Check22 = rs.Fields![Verified]
Me.RecordID = rs.Fields![RecordID]
Me.EmpID = rs.Fields![EmpID]
rs.MoveNext
Loop
End If
Stepping through the code I get 13 subform records for the first EmpID (which is the correct #) But --- and here's my problem: On the form itself I have displayed the last record 13 times, not 13 records 1 time each. It's almost as if I need to have a me.movenext but there isn't any. Any suggestions out there?