Populate a field based on a visible value in a combo box?



I have a main form with a combo box, and a subform which is linked to the
main form combo box, as a Child link. I have already synchronized the form
to the combo box, through a "SetValue" macro. I have an identical field in
both forms, based on a lookup table. I would like to limit the choice for
selection of this field in the subform (in datasheet view) based on the
current selected record in the main form. This field is also linked in the
query as a one-to-many join (the subform being the many portion, as it's
purpose is to write multiple entries to a particular table). Any help
greatly appreciated.

Here is what I attempted:

Created a validation rule (below) on the field in the subform to be equal to
the value in the combo box (or Null).


Now the problem is when entering data in the matching field in the subform
it displays in the datasheet, but when exiting the form it recognizes the
value as null.

Another option may be a VBA script to copy the visible value from the combo
box to the subform entry for that field.

Any help?


It is accurately now populating the default value in the subform, based on
the combo box value, but I noticed that when selecting a value in the combo
box (in the main form), it disappers following selecting it. Therefore, when
clicking in the matching field in the subform, I get an error that I cannot
enter Null values in the field (because the macro is making it default to the
null value in the combo box).


The macro is now working, but when selecting a value in the combo box (on the
main form) that does not already have an equivalent value in the matching
field on the subform (foreign key) the value does not apper in the combo box
field. Therefore the macro returns a message also, that cannot enter a null
value (because I have the table this field is based on to require input).
But, I cannot understand why the combo box is defaulting to null when making
a selection based on the above stated criteria.

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