
Perform a go to new rec w/ retaining some info from prev rec
Call this function from the on current event of the form. Put the word
"retain" in the tag property for any field that you would like repeated.
Most programmers would tell you to store the address in a separate table and
connect family members to the address using a FamilyID. What happens when
their address changes, you will have to go to all family members and change
their address.
Phil
Function AutoFillNewRecord(F As Form)
Dim RS As 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
F.Painting = False
' Visit each field on the form.
For Each C In F
If C.Tag = "retain" Then
C = RS(C.ControlSource)
End If
Next
F.Painting = True
End Function
Quote:
> Client wants to be able to go to a new rec, but retain info from the
> previous rec. For example, a new rec for each family mamber, but the
address
> would stay the same. Obviouly, having to key in the address for each
family
> member would be a waiste of time. Could someone show me how to code this?
> Many thanks, Arthur