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!

COPY A PREVIOUS RECORD

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 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 = &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 this

FillFields = &quot;;&quot; & f![AutoFillNewRecordFields] & &quot;;&quot;
its like this
x = AutoFillNewRecordFields()

You are trying to pass results form a function into a form object which will not work.

What are you trying to do????

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