After update issue

D

dab1477

I have redirected this post from Coding to here...

I have a subform titled NewPartsSubForm. Within this form, I have a combo box
labled as Rtg_oper_num. I am able to choose from a listing of routings within
the box (I choose 100, 120, 140, 32156 etc from a listing). I want to
populate a Description filed within this same subform based upon the entry I
choose in the Rtg_oper_num field. I have a table call Operations, where I
have the operation number in one column and the operation descripton in an
adjacent column. I am trying to lookup the Rtg_oper_num entry on the subform;
match it to the Operation Number in the Operations table, and return the
Operation Description from the Operations table to the Description field on
the subform. At this point I have the following Afterupdate coded for the
Rtg_Oper_num field in the subform;
if RTG_OPER_num>0 then
me.oper_desc.value=DLookUp("[Oper_Desc]","[operations]","[rtg_oper_num]=Forms![newpartsubform]![rtg_oper_num]")
End if
End Sub

At this point I get the SAME value for all Decription Fields regardless of
the value of the RTG_oper_num field. Where am I going wrong? Thanks.

I'm fairly new to VBA. Your patience is appreciated.
 
M

Marshall Barton

dab1477 said:
I have redirected this post from Coding to here...

I have a subform titled NewPartsSubForm. Within this form, I have a combo box
labled as Rtg_oper_num. I am able to choose from a listing of routings within
the box (I choose 100, 120, 140, 32156 etc from a listing). I want to
populate a Description filed within this same subform based upon the entry I
choose in the Rtg_oper_num field. I have a table call Operations, where I
have the operation number in one column and the operation descripton in an
adjacent column. I am trying to lookup the Rtg_oper_num entry on the subform;
match it to the Operation Number in the Operations table, and return the
Operation Description from the Operations table to the Description field on
the subform. At this point I have the following Afterupdate coded for the
Rtg_Oper_num field in the subform;
if RTG_OPER_num>0 then
me.oper_desc.value=DLookUp("[Oper_Desc]","[operations]", _
"[rtg_oper_num]=Forms![newpartsubform]![rtg_oper_num]")
End if
End Sub

At this point I get the SAME value for all Decription Fields regardless of
the value of the RTG_oper_num field. Where am I going wrong? Thanks.


If you are using a continuous or datasheet form, seeing the
same value on each row is the way it works when you set an
unbound control's value using code.

BTW, you do not need to use code to display the description.
If the combo box's row source query includes the description
in the second column, then the Oper_Desc text box can
display the description by using this expression:
=Rtg_Oper_num.Column(1)

To get the related value on each row, you can use DLookup in
the text box's control source:
=DLookup("Oper_Desc","operations","rtg_oper_num=" &
rtg_oper_num")

BUT that can easily be too slow to be useful.
 

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