Passing field names

M

Max

Hi,
I have written a function that takes a record ID, two field names and the
document name to determine the interval between two dates and print and
invoice reminder if more than 28 days have passed.

The code is called with:
UpdateInvDate .[Patient ID], "Invoice Reminder Third", "Invoice
Reminder Second", "FirstReminder"

At this line I get an error: not found in this collection:
If DateDiff("d", .Fields(FldName), .Fields(FldParent)) > 28 Then

I would be grateful for some guidance.

Max

Here is part of the function:

Private Function UpdateInvDate(varID As Long, DocName As String, FldParent
As String, FldName As String)

On Error GoTo Err_UpdateInvDate
Dim rs As Recordset, PatID As Long, Criteria As String

'Check for records to merge
Criteria = "[Patient ID] = " & varID
Set rs = Forms![Invoicing]![DebtorList].Form.RecordsetClone
With rs
.MoveLast 'Triggers error if no more records to merge
.MoveFirst
.FindFirst Criteria
If .NoMatch Then Exit Function
Do Until rs.EOF
'Check if reminder sent, if not, and more than 28 days past, action.
If DateDiff("d", .Fields(FldName), .Fields(FldParent)) > 28 Then
DoCmd.OpenReport DocName, acNormal, , "ID = " & varID
DoEvents
.Edit
.Fields(FldName) = Date
.[Account Sent] = -1
.Update
.Requery
End If
loopline:
.FindNext Criteria
Loop
End With
 

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