link 2 Child fields to 2 Master fields.

  • Thread starter Thread starter Pradeep
  • Start date Start date
P

Pradeep

I know i can link two child fields (of a subform) to 2 master fields.
But my problem is if i pass only one of the master fields, then it
does not display records. I want that if the user passess any one
Master values, the subform should display display values based on that
one value. I thought this is possible thru code, even that did not
work out.

Any help is appreciated.
 
Simplest solution might be to leave the LinkMasterFields and LinkChildFields
blank, and use the Current event of the main form to assign a SQL string to
the RecordSource property of the form in the subform control. The SQL string
will have 1 or 2 phrases in the WHERE clause, depending on whether the 2nd
text box on the main form IsNull().

Note that after assigning the RecordSource, Access may (over-helpfully)
assign the LinkMasterFields and LinkChildFields, so you may have to
explicitly clear them in your code also.

An alternative approach would be to use the 1st field in the
LinkMasterFields and LinkChildFields, and then set the Filter of the subform
in the AfterUpdate of the 2nd. This approach is likely to run into problems
if you filter the main form as well. Details:
http://members.iinet.net.au/~allenbrowne/bug-02.html
 
Back
Top