A
Amit
Hi,
I have a form with a combo-box, some bound controls, and
an unbound control which uses DLookUp to get its value,
using the value selected in the combo-box.
I'd like the unbound control to display the value for both
instances - a new record, and an existing record.
Where all will I have to place 'DLookUp' to accomplish
this? (in the Form events, or the combo-box afterupdate
event? or both?)
Will I need to use the 'Me.Requery' statement? Where?
I've tried accomplishing this, and the value is calculated
correctly, but sometimes, the value is not showing
properly when I navigate from one record to the next (it
carries over the value from the previous record), and
other times, when I navigate through existing records, it
sets the value of another comboBox on the form to 0.
Obviously, I'm not placing the code in proper events.
Here's some pseudo-code/logic--
==========================================
cboBound AfterUpdate event:
call assign_value
Me. requery
==========================================
Form OnCurrent event:
If Me.NewRecord and IsNull(cboBound) Then
txtUnbound = 0
else
call assign_value
==========================================
Sub assign_value()
Dim varFee as Variant
varFee = DLookUp(...)
If IsNull(varFee) Then
txtUnbound = 0
Else
txtUnbound = varFee
End If
End Sub
============================================
Thanks for any help/pointers!
-Amit
I have a form with a combo-box, some bound controls, and
an unbound control which uses DLookUp to get its value,
using the value selected in the combo-box.
I'd like the unbound control to display the value for both
instances - a new record, and an existing record.
Where all will I have to place 'DLookUp' to accomplish
this? (in the Form events, or the combo-box afterupdate
event? or both?)
Will I need to use the 'Me.Requery' statement? Where?
I've tried accomplishing this, and the value is calculated
correctly, but sometimes, the value is not showing
properly when I navigate from one record to the next (it
carries over the value from the previous record), and
other times, when I navigate through existing records, it
sets the value of another comboBox on the form to 0.
Obviously, I'm not placing the code in proper events.
Here's some pseudo-code/logic--
==========================================
cboBound AfterUpdate event:
call assign_value
Me. requery
==========================================
Form OnCurrent event:
If Me.NewRecord and IsNull(cboBound) Then
txtUnbound = 0
else
call assign_value
==========================================
Sub assign_value()
Dim varFee as Variant
varFee = DLookUp(...)
If IsNull(varFee) Then
txtUnbound = 0
Else
txtUnbound = varFee
End If
End Sub
============================================
Thanks for any help/pointers!
-Amit