DLookup function

stevemccauley

Registered User.
Local time
Today, 03:44
Joined
Aug 8, 2001
Messages
75
On my form I'm using the DLookup function in a formula, but the DLookup won't run until I change the form to edit, then back to form. Do I have to add a button to refresh the form or something?
 
Something must trigger the code to execute. Where do you have the formula / function? Wherever it is, it will only happen when that event takes place, such as ON OPEN of the form, or ON EXIT of a particular control.
 
In the properties of your textbox add

Me.Requery

to the after Update event
 
I have 1 cbobox and 1 textbox(with DLookUp formula). When a name is selected from the cbobox the DLookUp textbox is supposed to run a calulation according to the name selected. But the calculation doesn't run. The DLooUp function is entered into the control source of the textbox. How do I get the text box to run the DLookUp after the cbobox is changed?
 
Sorry, my mistake.
Put the Me.Requery on the after change event of your combobox
 
This is what I have now:

Private Sub cboVessel_Change()

Me.Requery

End Sub

But the textbox still doesn't run the DLookUp calculation. The name of the textbox is Speedtxt. Do I have to enter something else?
 
Are you sure the DLookup formula is correct?
 
Yes, because when the form is switched from design back to form view the DLookUp function calculation works. Could I add a button that would refresh the form or something?
 
You can try creating a command button and on the OnClick event put the Me.Requery line.
 
I would suspect that you need to save the record first then Requery the textbox
 
Its working now, thanks.


cbobox = cboVessel
textbox = SpeedHRS


This is the code.


Private Sub cboVessel_Change()
Me.SpeedHRS.Requery
End Sub
 
You should use the after update event, not the change. The change event will trigger for every letter that you type into the combo
 

Users who are viewing this thread

Back
Top Bottom