Hello Access Experts,
I get the error:
MS Access can't find the field 'AutoFillNewRecord Fields' referred to in your expression
I get the error on the code line:
FillFields = ";" & f![AutoFillNewRecordFields] & ";"
I have the Tools-Reference: MS DAO 3.6 OB Lib checked. I'm using the code I found at Microsoft to copy a previous record to a new record. I don't know why I get the error on the code below.
Any help is appreciated. Thanks!
I'm not real proficient with VBA yet.
-----------------------------------------------------------------------
Function AutoFillNewRecord()
Dim RS As DAO.Recordset, C As Control, f As Form
Dim FillFields As String, FillAllFields As Integer
On Error Resume Next
'Dim f As Form, strDocName As String
Set f = Forms!frmWills
' Exit if not on the 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
g_strCurrentAutofillRecord = f.CurrentRecord
' 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 autofilled.
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 FillAllFields Or InStr(FillFields, ";" & (C.Name) & ";" > 0 Then
C = RS(C.ControlSource)
End If
Next
f.Painting = True
End Function
I get the error:
MS Access can't find the field 'AutoFillNewRecord Fields' referred to in your expression
I get the error on the code line:
FillFields = ";" & f![AutoFillNewRecordFields] & ";"
I have the Tools-Reference: MS DAO 3.6 OB Lib checked. I'm using the code I found at Microsoft to copy a previous record to a new record. I don't know why I get the error on the code below.
Any help is appreciated. Thanks!
I'm not real proficient with VBA yet.
-----------------------------------------------------------------------
Function AutoFillNewRecord()
Dim RS As DAO.Recordset, C As Control, f As Form
Dim FillFields As String, FillAllFields As Integer
On Error Resume Next
'Dim f As Form, strDocName As String
Set f = Forms!frmWills
' Exit if not on the 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
g_strCurrentAutofillRecord = f.CurrentRecord
' 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 autofilled.
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 FillAllFields Or InStr(FillFields, ";" & (C.Name) & ";" > 0 Then
C = RS(C.ControlSource)
End If
Next
f.Painting = True
End Function