H
Humble David
I pulled this code from Allen Browne's web site. It
copies the values of text boxes and combo boxes in a
form. I am in "data entry" mode where users will enter
multiple records at one time (from a form). I want to
copy the value of user_id from one record to another as
they enter.
Here is the code... Can someone PLEASE explain this to
me in ENGLISH?
Do I just change the i to user_id?
http://members.iinet.net.au/~allenbrowne/ser-24.html
----- partial copy of code written by MVP Allen Browne
Sub CarryOver(frm As Form)
On Error GoTo Err_CarryOver
' Purpose: Carry the values over from the last record to
a new one.
' Usage: In a form's BeforeInsert event procedure,
enter:
' Call CarryOver(Me)
' Notes: This example limited to text boxes and combo
boxes.
' Text/combo boxes must have same Name as the
fields they represent.
Dim rst As DAO.Recordset
Dim ctl As Control
Dim i As Integer
Set rst = frm.RecordsetClone
If rst.RecordCount > 0 Then
rst.MoveLast
For i = 0 To frm.count - 1
Set ctl = frm(i)
If TypeOf ctl Is TextBox Then
If Not IsNull(rst(ctl.Name)) Then
ctl = rst(ctl.Name)
End If
ElseIf TypeOf ctl Is ComboBox Then
If Not IsNull(rst(ctl.Name)) Then
ctl = rst(ctl.Name)
End If
End If
Next
End If
copies the values of text boxes and combo boxes in a
form. I am in "data entry" mode where users will enter
multiple records at one time (from a form). I want to
copy the value of user_id from one record to another as
they enter.
Here is the code... Can someone PLEASE explain this to
me in ENGLISH?
Do I just change the i to user_id?
http://members.iinet.net.au/~allenbrowne/ser-24.html
----- partial copy of code written by MVP Allen Browne
Sub CarryOver(frm As Form)
On Error GoTo Err_CarryOver
' Purpose: Carry the values over from the last record to
a new one.
' Usage: In a form's BeforeInsert event procedure,
enter:
' Call CarryOver(Me)
' Notes: This example limited to text boxes and combo
boxes.
' Text/combo boxes must have same Name as the
fields they represent.
Dim rst As DAO.Recordset
Dim ctl As Control
Dim i As Integer
Set rst = frm.RecordsetClone
If rst.RecordCount > 0 Then
rst.MoveLast
For i = 0 To frm.count - 1
Set ctl = frm(i)
If TypeOf ctl Is TextBox Then
If Not IsNull(rst(ctl.Name)) Then
ctl = rst(ctl.Name)
End If
ElseIf TypeOf ctl Is ComboBox Then
If Not IsNull(rst(ctl.Name)) Then
ctl = rst(ctl.Name)
End If
End If
Next
End If