DLOOKUP

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that when it is opened it allows you to view all the data in a table. I want to use DLOOKUP when the form is in the "new record" mode only. Currently, DLOOKUP is causing problems when the form is initially opened and showing the previous record. I hope there is away to distinguish between "new record mode" versus "review mode." Please help!
 
I have a form that when it is opened it allows you to view all the data in a table. I want to use DLOOKUP when the form is in the "new record" mode only. Currently, DLOOKUP is causing problems when the form is initially opened and showing the previous record. I hope there is away to distinguish between "new record mode" versus "review mode." Please help!

I'm not sure what you want DLookUp to do; maybe you could consider
using it in the Form's BeforeInsert event, which fires the moment a
new record is created.
 
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.

Thanks for your assistance.
 
You could do it that way by setting a global variable (in amodule. 'Public var1 as date' or whatever) and then setting the variable to the value that you want to move from record to record, then use dlookup. If you are not moving huge amounts of data from form to form, why not move them all in globals?
 
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
 
Back
Top