Lookup Code Issue

K

kalyhan

Hi Everyone.

I'm having a small problem with my code. Perhaps someone can advise what I
am doing wrong??

All data is entered through a form. Users utilize several combo boxes which
pull repeatitive info from various tables. One combo box is based on the
MaterialCostTable which contains 3 columns - AutoNum, MaterialType and
CostPerFoot.

When the MaterialType is selected from the form's combo box, I want to pull
the appropriate CostPerFoot associated with the MaterialType. I used the
following code (on exit) listed at the end of this msg. A cost does show
up, but always displays $1.00, instead of the correct amount. What am I
doing wrong?

***********************************************
Private Sub MaterialType_Exit(Cancel As Integer)
Dim varCostPerFoot As Variant
varCostPerFoot = DLookup("CostPerFoot", "MaterialCostTable",
"MaterialType =[MaterialType] ")
If (Not IsNull(varCostPerFoot)) Then Me![CostPerFoot] = varCostPerFoot
End Sub
************************************************

Thanks in advance for any assistance!

Karen
 
A

Albert D. Kallal

All data is entered through a form. Users utilize several combo boxes
which
pull repeatitive info from various tables. One combo box is based on the
MaterialCostTable which contains 3 columns - AutoNum, MaterialType and
CostPerFoot.

use the after udpate event of the combo box to set the value.

eg:

varCostPerFoot = me.MycomboBox.Column(2)

the column() function is 0 pbased, so 2 = 3rd collum ffrom combo box..

You can also stuff that vlaue into a contorl on the form

me.MyCostcontorl = me.MyComboBox.Column(2)
 
K

kalyhan

I shall try this. Thank You Albert!

Albert D. Kallal said:
use the after udpate event of the combo box to set the value.

eg:

varCostPerFoot = me.MycomboBox.Column(2)

the column() function is 0 pbased, so 2 = 3rd collum ffrom combo box..

You can also stuff that vlaue into a contorl on the form

me.MyCostcontorl = me.MyComboBox.Column(2)
 

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