problem with 2 simular subforms

dirkvw

Registered User.
Local time
Today, 23:23
Joined
Oct 11, 2013
Messages
15
Is it possible to show on a form 2 times the same subform but the first time filled with records where a field (categorie) has the value 1, the second time where this value = 2.
Of course, I know I can make 2 nearly the same subforms, where I only change the data-conditions, but it feels like not to be the best solution.
 
Create a pseudoname for each subform and use the "real" subform as the psuedoforms control source adjust each record source appropriately.
 
or you can make use of the linkchild and linkmaster properties

Then you don't have to mess with the recordsource

create two hidden textboxes, call them say sf1 and sf2, set the controlsource to =1 in the first and =2 in the second.

Assuming your 'normal' link is tblID in both mainform and subform then the first subform you would set

linkchild to tblID;sf1
linkmaster tblID;Category

and for the second subform

linkchild to tblID;sf2
linkmaster tblID;Category
 
Thanks to IIkhoutx and CJ London for helping me.
IIkhoutx:
...and adjust each record source appropriatly.
How can I do that? I only see the second subform as a white window. When I select it, it seems not to be possible to set a filter in the properties .
CJ London:
I tried this method already, but failed because I used the help of ACCESS to fill in the linking fields in the properties (always got an error-message). Now I did it by just typing the text in the properties-window, and it works like a charm!

I stil have a little problem. On the subform I have a command button to open another form. How can I know from which subform I used that command button. If I use Me.name, I get the name of the real subform, if I use me.caption I get "". (In the properties I filled in by subform1 sub1, by subform 2 sub2). I need to know this for setting the openargs of the opening form.
 
Code:
 How can I know from which subform I used that command button
you could refer to the category since that has been linked

e.g.

Code:
 select case category
     case 1
         'openargs =this
     case 2
         'openargs=that
     case else
         'msgbox "something not right"
 end select
 
Of course! that's so logical that I'm ashamed I did't find the solution myself.
Many thanks and a great weekend.
Dirk
 

Users who are viewing this thread

Back
Top Bottom