G
Guest
Hi,
I have a form that I'm using to enter a variety of data types: text,
date/time & Yes/No. The form has 87 fields, many of which are identical from
one consecutive record to the next (and in any series of records, many these
may be blank).
What would speed up data entry for me enormously would be to copy values
from the previous record into the new record automatically. My problem is
finding a way to achieve this for the Yes/No fields. I know essentially
nothing about visual basic, and I have little prior experience with Access
(I'm using Access 2003).
I have been able to do this for those date/time & text fields for which this
is appropriate using the info presented here: "How to fill record with data
from previous record automatically in Access 2000"
(http://support.microsoft.com/?kbid=210236), which creates an
AutoFillNewRecord() function:
------------------------
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
----------------------
....but haven't found an obvious way to make this work for the Yes/No values.
Any help gratefully appreciated!
Thanks!
I have a form that I'm using to enter a variety of data types: text,
date/time & Yes/No. The form has 87 fields, many of which are identical from
one consecutive record to the next (and in any series of records, many these
may be blank).
What would speed up data entry for me enormously would be to copy values
from the previous record into the new record automatically. My problem is
finding a way to achieve this for the Yes/No fields. I know essentially
nothing about visual basic, and I have little prior experience with Access
(I'm using Access 2003).
I have been able to do this for those date/time & text fields for which this
is appropriate using the info presented here: "How to fill record with data
from previous record automatically in Access 2000"
(http://support.microsoft.com/?kbid=210236), which creates an
AutoFillNewRecord() function:
------------------------
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
----------------------
....but haven't found an obvious way to make this work for the Yes/No values.
Any help gratefully appreciated!
Thanks!