Here is what I'm trying to accomplish. When the typist is entering data, several fields are always redundant, for example, period, month, and year when entering time cards for over 200 employees. Each time the typist moves to a new record, he or she must re-enter 1 for 1st period, 11 for month, and 03 for year. If the typist has previously entered this information, I would like to access the previous record and populate the new record with this information and allow the operator to change it if it is different. This is my goal and I thought that DLookup could help, but it can't by itself.
There's actually a much easier way to do this! You can set the Default
property of selected controls on the Form to the last value entered in
that control; if you set the control's Tab Stop property to False, the
typist will need to mouseclick into the field only once, for the first
record, and type a value. Subsequent records will default to the most
recently entered value (until the typist manually selects and changes
the field again).
In the textbox's AfterUpdate event for textbox txtPeriod, for example,
select the Code Builder by clicking the ... icon and choosing Code
Builder. Edit the code to something like
Private Sub txtPeriod_AfterUpdate()
If Me!txtPeriod & "" <> "" Then ' Did user enter any data?
' if so, set the control's Default property to its current content
' The Default property is a String and needs quotes (Chr(34) is ")
Me!txtPeriod.Default = Chr(34) & Me!txtPeriod & Chr(34)
End If
End Sub