Value of an unbound control on a form

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
 
J

Jeff Boyce

Amit

I didn't see anything in the code you listed that would set your bound
combobox to 0, so I don't have any ideas on that.

I'd suggest setting a breakpoint in your OnCurrent event procedure (near the
start). That way, when you move to a new record, you can step through your
code, line-by-line, and see what is being triggered and what isn't.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top