Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

run time error 2465

Status
Not open for further replies.

prawdzik

Technical User
May 25, 2001
3
US
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. I don't know why I get the error on the code below.
Any help is appreciated. Thanks!

P.S. It used to work fine a while back and 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 = &quot;;&quot; & f![AutoFillNewRecordFields] & &quot;;&quot;

' 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, &quot;;&quot; & (C.Name) & &quot;;&quot;) > 0 Then
C = RS(C.ControlSource)
End If
Next
f.Painting = True

End Function
 
you can't call a function like that when it wants text
FillFields = &quot;;&quot; & f![AutoFillNewRecordFields] & &quot;;&quot;


But I'm not sure what you are doing to help
try calling the function outside

Dim AutoFill as String
AutoFill = AutoFillNewRecordFields()
?????
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top