Hi
I have the following code which loops through the records in a recordset and tells me if the previous record is the same as the current record.
What I now need to do is, update the current record with the next invoice number (taken from the tblInvoices using DMax) and move to the next record (which it does) and if its the same account number then add the same invoice number otherwise if its different get the last invoice number and add 1
Thanks
I have the following code which loops through the records in a recordset and tells me if the previous record is the same as the current record.
Code:
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim qd As DAO.QueryDef
Dim AccountNumber As String
Set db = CurrentDb
Set qd = db.QueryDefs!Query1
qd.Parameters![Forms!frmDashboard!InvoiceFromDate] = [Forms]![frmDashboard]![InvoiceFromDate]
qd.Parameters![Forms!frmDashboard!InvoiceToDate] = [Forms]![frmDashboard]![InvoiceToDate]
Set rs = qd.OpenRecordset
AccountNumber = rs!AccountNumber
Do While Not rs.EOF
If rs!AccountNumber = AccountNumber Then
'same Account number
MsgBox "Same account"
Else
'different Account Number
MsgBox "different account"
End If
rs.MoveNext
Loop
'Catch the last owner here
rs.Close
What I now need to do is, update the current record with the next invoice number (taken from the tblInvoices using DMax) and move to the next record (which it does) and if its the same account number then add the same invoice number otherwise if its different get the last invoice number and add 1
Thanks