Re: I'm not so smart
by John Vinson » Fri, 14 May 2004 10:40:43 GMT
n Tue, 11 May 2004 20:11:08 -0700, "Humble David"
< XXXX@XXXXX.COM > wrote:
No. i is just a loop variable.
The code as written goes through ALL of the textboxes and combo boxes
in the entire Form (not just one of them). I'll comment the code on
the following line...
If the code encounters an error, execution will jump to the line
labeled Err_CarryOver.
Reserve a variable named rst for a Recordset object
reserve a variable named ctl for a Control object (e.g. a textbox)
reserve a variable named i as an Integer
Set the variable rst to the current form's RecordsetClone property,
i.e. the set of records available for display on the Form
Check to see if the form actually HAS at least one record
If so, move to the last (most recently entered) record
Loop through all the Controls on the form, starting from the last and
looping backwards. Me.Controls(i) will be a pointer to the i'th
control.
Set the variable ctl to the Control object in the i'th position
Is this control a Textbox?
And does it have a Name property? (a bit odd, all controls do)
Assuming (as in the comment above) that the name of the control is
identical to the name of the field displayed in that control, set the
default Value property of the control to the value of that field in
the Form's RecordsetClone
Similar logic for Combo Box controls
If the control is neither a textbox nor a combo box, don't do anything
- just loop to the next control
Hope this helps!
It may be simpler to JUST carry over the User_ID: you could use the
following code in the User_ID control's AfterUpdate event:
Private Sub User_ID_AfterUpdate()
' this code will run when the user enters a value into the UserID
' control. If that control is named, say, txtUser_ID, change the
' name as appropriate.
Me!User_ID.DefaultValue = Chr(34) & Me!User_ID & Chr(34)
' Set the DefaultValue property of the control to a text string
' delimited by " - Chr(34) - containing whatever the user entered.
' When the user moves to the new record, it will now default to
' whatever they last typed.
End Sub
John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public