syntax parent frm hs combobox want to grabvalue frm combo based on

B

babs

Still no answer need by tomorrow AM-thanks for helping!

I have a Main form named DateBarb with a combo box cboman - It has the Man
name with rate1 in the second column and rate2 in the third column of
combobox


On the subform if the field name [ckRate2BP] is checked I want field in the
subform [ActualRate] (I Named it txtActualRate) but field name is
[actualrate] to grab the the rate2 from the combobox:

Here is my code below - I attached it to the afterupdate event of the
ckRate2BP field on the subform - but also not sure if that is best place
since many times user may not even click on this check box if not second
rate.

I am sure my syntax in referencing the field names and forms in incorrect -
Please help.

datbarbTimeCardMDJEFFSubform2!txtActualRate =
IIf(Me.Form!datbarbTimeCardMDJEFFSubform2!ckRate2BP = yes,
Me.Form!DateBArb!cboman.Column(2), Me.Form!DateBArb!.cboman.Column(1))

Thanks,
Barb
 
D

Dirk Goldgar

babs said:
Still no answer need by tomorrow AM-thanks for helping!

I have a Main form named DateBarb with a combo box cboman - It has the Man
name with rate1 in the second column and rate2 in the third column of
combobox


On the subform if the field name [ckRate2BP] is checked I want field in
the
subform [ActualRate] (I Named it txtActualRate) but field name is
[actualrate] to grab the the rate2 from the combobox:

Here is my code below - I attached it to the afterupdate event of the
ckRate2BP field on the subform - but also not sure if that is best place
since many times user may not even click on this check box if not second
rate.

I am sure my syntax in referencing the field names and forms in
incorrect -
Please help.

datbarbTimeCardMDJEFFSubform2!txtActualRate =
IIf(Me.Form!datbarbTimeCardMDJEFFSubform2!ckRate2BP = yes,
Me.Form!DateBArb!cboman.Column(2), Me.Form!DateBArb!.cboman.Column(1))


If the code is running in the AfterUpdate event of the ckRate2BP control on
the subform, then the subform is "Me" and you just need to know how to refer
to the subform's parent form. Try this:

'------ start of example code ------
Private Sub ckRate2BP_AfterUpdate()

If Me.ckRate2BP = True Then
Me.txtActualRate = Me.Parent!cboman.Column(2)
Else
Me.txtActualRate = Me.Parent!cboman.Column(1)
End If

End Sub
'------ end of example code ------

That implements what I understand to be the logic of what you were
attempting with your code as quoted above.

However, be aware that this code will only execute if someone actually
changes the value of the check box. If you are creating a new record on the
subform and don't check the ckRate2BP box, txtActualRate will not be
assigned *any* value, not rate1 nor rate2, because the AfterUpdate event
won't fire. You may need additional code to ensure that the rate is set
properly.
 

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