Trouble with autofill module

N

**Natasha

Someone please tell me what needs to be changed in
this module to autofill just one field called [LockinDate].
Thanks!

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 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

' 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
 
A

Alex Dybenko

change this line
If FillALLFields Or InStr(FillFields, ";" & (C.Name) & ";") > 0 Then
to
If C.Name="LockinDate" then
 

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