Repeat last entry

blueboron

Registered User.
Local time
Today, 04:31
Joined
Aug 2, 2005
Messages
18
Hi,

I would like to know what code I need to populate a field with the last record information - similar to the Ctrl apostophe.

I can upload the database in question if required.

Thank you
 
In the control's AfterUpDate event, try adding:
Me!YourControlName.DefaultValue = Me!YourControlName.Value
hth.
 
Many thanks quest4 tried it but it does not work
 
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
 
Strange, it works on a half-dozen txtboxes on my form, I am daffled. Stupid question here, on the above problem, you do have the DAO 3.6 library checked in the reference pull-down don't you? I sometimes miss that one. hth.
 
Not to certain what you mean by your last question about library but I think the answer is no - can you explain a bit further please
 
in the vba window choose Tools - References and see if there is a check box next to Microsoft DAO 3.6
 
Thank you - it would seem that I only have Microsoft DAO 3.5
 
In the tooling drop-dow of the vb editor, select references. See if DAO 3.6 library is checked, if not check it. That loads it into the dbase for use. If it was not checked it will cause a world of problems, which will immediately clear up when you check it. hth.
 
I have checked Microsoft DAO 3.6

I can now open the recordset with no error but it still will not autofill the fields with previous data
 
Last edited:
Great, glad it is working for you. Good luck with the rest of your project.
 

Users who are viewing this thread

Back
Top Bottom