B
babs
below is code that I used on a different database that worked well to
automatically populate the new record based on values inprevious record but
it was only a single form:
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 auofill 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 Fill Fields list.
If FillAllFields Or InStr(FillFields, ";" & (C.Name) & ";") > 0 Then
C = rs(C.ControlSource)
End If
Next
F.Painting = True
End Function
With the new database I have a Main form (for the Week End Date)and schedule
of jobs for that given week in the Subform. ex. possible 8 employees list
6times in subform for Mon-Sat. jobs
When navigate to new record(new week) [or Prob. should tie to a command
button- to insert records} on Main form I want to autofill the new subform
with Each persons([man]) previous record from the Fri([day]-field name).
Insert Mon-Fri for all previous sched. people -prior record and grab job
name they were on that Fri - Since sat. jobs are odd jobs and 9Xout of 10
the new week schedules is usually where they left off on Fri. -
I currently have a command button with the following code but it only
inserts the six new records based on who is selected in the man drop down
list - would like it to grab the job from the previous record - Friday.???any
ideas???
thanks,
barb
automatically populate the new record based on values inprevious record but
it was only a single form:
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 auofill 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 Fill Fields list.
If FillAllFields Or InStr(FillFields, ";" & (C.Name) & ";") > 0 Then
C = rs(C.ControlSource)
End If
Next
F.Painting = True
End Function
With the new database I have a Main form (for the Week End Date)and schedule
of jobs for that given week in the Subform. ex. possible 8 employees list
6times in subform for Mon-Sat. jobs
When navigate to new record(new week) [or Prob. should tie to a command
button- to insert records} on Main form I want to autofill the new subform
with Each persons([man]) previous record from the Fri([day]-field name).
Insert Mon-Fri for all previous sched. people -prior record and grab job
name they were on that Fri - Since sat. jobs are odd jobs and 9Xout of 10
the new week schedules is usually where they left off on Fri. -
I currently have a command button with the following code but it only
inserts the six new records based on who is selected in the man drop down
list - would like it to grab the job from the previous record - Friday.???any
ideas???
thanks,
barb