Help to set Link Child/Master Fields Property

Debased

Registered User.
Local time
Yesterday, 19:17
Joined
Mar 11, 2004
Messages
112
I need to know how to write the vb code for changing the Link Childs/Master properties for subforms. I have searched the Help files but not much "help"!

I have a form with 2 subforms. I want the Link Childs Field & Link Master Field properties for both subforms to be triggered by what is displayed in a field called GroupNumber located on the main form. If the field is null set child/master to x if not null set to y:

If IsNull(Me.GroupNumber) then

[set the link properties to X] (need code here)

Else

[set the link properties to Y] (need code here)

End If

I know I can access the property this way: "SubformName.LinkChildFields"
but I don’t know where to go from there. :(
Would appreciate an example of how this is done.

Thanks very much!! :D
 
Do you still need help on this?
 
Yes...just got into the office..I do still need help..thanks :)
 
I would think you already tried:

SubformName.LinkChildField = table _one.field_one

??
 
Yes I did and I got a pop up box that displayed the field contents in the message and a blank box asking for a parameter.
 
Do you change the record source for the sub form first?
 
Not sure I understand your question. The coding I use to change the Child/Master Link of the sub form is in the main form's Current event. Could this be the problem?

The pop up msg asking for a parameter appears when I go from one record to the next record on the main form.

I am not sure what you mean by "change the record source"

Thanks
 
The record source is just another property you can change on the form.

forms!form_one.recordsource = table_one
 
Right. No I do not change the record source. It stays the same throughout.
Thanks
 
Sorry but now I'm confused. If GroupNumber is null then what do you want to do? Hide the subform or change what is being displayed in the subform? If you want to change what is being displayed, then I would think you would want to change the recordsource first and then change the links...
 
Sorry for the confusion. I was trying to keep it simple as possible.

The main form displays a physician name. the subforms (there are 2) display audit scores based on the physician number. this is the child/master link for most physicians. Some physicians however, belong to a group. If they belong to a group I want to display the group score not the individual physician score. so the child/master link has to change to group number. The record source has both group and physician number so it does not need to change.

I thought one way to do this is to have the child/master link change dynamically. If there is no group name in the group field, use the provider number, if there is a group name then use the group number.

If this still does not make sense let me know or if you have a better idea I am open. I am fairly new to this (OBVIOUS)…and I appreciate your replies.
 
Hum... Interesting. I would probably have just put the two subforms on a tab control and add two more subforms on another tab called 'Group'.

I've never tried to change a link dynamically. You may have a relationship/key issue. I'll tinker with it and see what happens.

Sounds like you may have normalization issues as well...
 
Thanks for your replies up until now. Your reply before your last one gave me an idea that may be easier than what I am trying to do now. So for now let's just drop this thread. I am going to work on the record source idea. Thanks again!
 

Users who are viewing this thread

Back
Top Bottom