Populate subform field on Afterupdate of main form field

R

RW

I have a combo box in a main form. On afterupdate, I need to compare the
selection with data in a field on the subform and then populate another field
on the subform with a result.

I have tried, I think, all iterations for
if forms!mainform!controlname = Forms!mainform.subform!controlname then
Forms!mainforn.subform!controlname = "OK"
Else
Forms!mainforn.subform!controlname = "Problem"
End If

I've even tried to setfocus on the subform before trying to populate the
subform controlname field. What am I doing wrong? If I write the code in an
afterupdate of the subform to compare to a field in the main form, I can
populate the difference field in the subform without any problems - but I
need to compare the fields from the main form.

Any help is appreciated.
 
J

Jack Leach

Try using a different syntax. Something like:

Me.subformcontrol.Form.controlname

controlname in this case would be the name of the control located on the
subform. subformcontrol needs to be the name of the Control, not the name of
the Form.

This may come in handy as well...
http://mvps.org/access/forms/frm0031.htm

hth
--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
R

RW

I tried that too ( I used the cheat sheet you linked to.). The subform
control referenced has the same name as the subform name.

One other issue is that the Afterupdate actually runs a function. This
function needs to run on afterupdate of the Mainform field and on afterupdate
of the subform field.
 
J

Jack Leach

Try using Me.control.Value instead of just me.Control

Technically, Me.Control returns the actual object itself, which access
generally converts to the .Value property. Issues may arise if access
doesn't see a specific reason to convert the object to a value.

It may not be the problem, but it's a place to start.

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 

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