refresh dlookup

deekras

Registered User.
Local time
Today, 22:26
Joined
Jun 14, 2000
Messages
169
i have a form that use dlookup to find info based on one field. that works fine. however, when i want to enter info for another prospect, the old one's info (that was obtained through dlookup) is still there. all the rest of the info is gone.

i want to have a clear form with no info at all. i guess i need to refresh the form; how do i do that?

also when i click the previous button, i want all the dlookup info to correspond to the previous info.
 
You don't say where or how you are using your DLookup so I would suggest the On Current event.....something like this:

If Me.NewRecord Then
Exit Sub
Else
Me.MyField = DLook(...)
End if

I hope I understood what it is you are trying to do...

Jack
 
i have the dlookup on the afterupdate of one of the fields. once a user enters a member number, the dlookup gets all his info.

on the oncurrent of the form, i have

Private Sub Form_Current()
If Me.NewRecord Then
Me.AllowEdits = True
Me.AllowDeletions = True
Me.AllowAdditions = True
Else
Me.AllowEdits = False
Me.AllowDeletions = False
End If

somewhere i want to say that if it is a new record, empty all the fields. right now, the info that was retrieved through dlookup is still there when i go to a new record.
 
A couple of things... I would use a combo box to fill the field(s) with the data rather than DLookup as it will be faster and easier for the user to find the correct member. I assume that the controls that being filled with data by DLookup are either onbound fields or DLookup is the in Control Source of the controls. If the controls are unbound then you will need to use code to clear the controls when you move to a new record. Just add the code to the current code in your On Current event. If you are using DLookup as the Control Source then switch to a Combo box and let it fill the controls and then set them to Null with the code as I mentioned.

hth,
Jack
 
deekras said:
i have a form that use dlookup to find info based on one field. that works fine. however, when i want to enter info for another prospect, the old one's info (that was obtained through dlookup) is still there. all the rest of the info is gone.

i want to have a clear form with no info at all. i guess i need to refresh the form; how do i do that?

also when i click the previous button, i want all the dlookup info to correspond to the previous info.

I agree that DLookUp is much slower than to place combobox with recordsource.
To refresh your form with lookup filed:

YourField.Requery
Me.Refresh

Text1=Null 'clear info
Text2=Null 'clear info
etc.

If you really want to go back(previous info) then why don't you insert this info like
"Insert into TempTable(Field1,Field2) values('Me.text1',Me.Text2')"
and show this info attached to your form?

Igor.
 

Users who are viewing this thread

Back
Top Bottom