I have tried the following but get this error message User defined type not defined
And the DAO.Recordset is highlighted in the following module
Function AutoFillNewRecord(F As Form)
Dim RS As DAO.Recordset, C As Control
Dim FillFields As String, FillAllFields As Integer
On Error Resume Next
' Exit if not on new record.
If Not F.NewRecord Then Exit Function
'goto the last record of the form recordset (to autofill form).
Set RS = F.RecordsetClone
RS.MoveLast
' Exit if you cannot move to the last record (no records).
If Err <> 0 Then Exit Function
' Get the list of fields to autofill.
FillFields = ";" & F![AutoFillNewRecordFields] & ";"
' if there is no criteria field, then set flag indicating All
' fields should be populated
FillAllFields = Err <> 0
F.Painting = False
'Visit each field on the form.
For Each C In F
'Fill the field if all fields are to be filled Or if the
' ... ControlSource field can be found in the FillFields list.
If fillSLLFields Or InStr(FillFields, ";" & (C.Name) & ";") > 0 Then
C = RS(C.ControlSource)
End If
Next
F.Painting = True
End Function