Linking subform to main form

J

Jeff

Hi All

I have a form and subform.

The form shown in the subform varies depending on which button (in the
mainform) is pressed. Each button changes the form shown in the Subform
space.

The forms are all syncronised like this:

Master:AlunoRef;AnodoCurso;SemestredoCurso
Child:AlunoRef;AnodoCurso;SemestredoCurso

The fields AnodoCurso and SemestredoCurso on the mainform are unbound
textboxes as number. The formats are the same for all fields.

The problem is:

When I open the mainform, everything works fine. When I change the form
in the subform by pressing a button, it doesn't filter the form in the
subform anymore, it shows the first register.

Sometimes it changes the links to:

Master:AlunoRef;
Child:AlunoRef;AnodoCurso;SemestredoCurso

I've tried coding in VBA:

Me.SubDetails.LinkChildFields = "AlunoRef;AnodoCurso;SemestredoCurso"
Me.SubDetails.LinkMasterFields = "AlunoRef;AnodoCurso;SemestredoCurso"

But this gives an erro message:

the number of master fields must be the same as the child fields.

When I put the cursor ove the line, the child shows perfect but the
master only shows AlunoRef.

I can't figure this out.

Any ideas? I really need to get this working!

Thanks

Jeff
 
M

Marshall Barton

Jeff said:
I have a form and subform.

The form shown in the subform varies depending on which button (in the
mainform) is pressed. Each button changes the form shown in the Subform
space.

The forms are all syncronised like this:

Master:AlunoRef;AnodoCurso;SemestredoCurso
Child:AlunoRef;AnodoCurso;SemestredoCurso

The fields AnodoCurso and SemestredoCurso on the mainform are unbound
textboxes as number. The formats are the same for all fields.

The problem is:

When I open the mainform, everything works fine. When I change the form
in the subform by pressing a button, it doesn't filter the form in the
subform anymore, it shows the first register.

Sometimes it changes the links to:

Master:AlunoRef;
Child:AlunoRef;AnodoCurso;SemestredoCurso

I've tried coding in VBA:

Me.SubDetails.LinkChildFields = "AlunoRef;AnodoCurso;SemestredoCurso"
Me.SubDetails.LinkMasterFields = "AlunoRef;AnodoCurso;SemestredoCurso"

But this gives an erro message:

the number of master fields must be the same as the child fields.

When I put the cursor ove the line, the child shows perfect but the
master only shows AlunoRef.

I can't figure this out.


Neither can anyone else.

This kind of Link Master/Child problem seems to pop up out
of nowhere every once in a while, but pinning it down has
been very difficult. About the only clue that seems
relatively consistent is that the same field name occurs in
both the main form and the subform's record source, usually
as a key field.

I'm just guessing here, but you may be able to avoid the
problem by aliasing the AlunoRef field in the main form's
record source query (also try making the name of the text
box bound to that field different than the field name?)

Another thing you can try is to set the Link Master/Child
properties to "", before setting them to what they should
be.
 
J

Jeff

Marshall said:
Neither can anyone else.

This kind of Link Master/Child problem seems to pop up out
of nowhere every once in a while, but pinning it down has
been very difficult. About the only clue that seems
relatively consistent is that the same field name occurs in
both the main form and the subform's record source, usually
as a key field.

I'm just guessing here, but you may be able to avoid the
problem by aliasing the AlunoRef field in the main form's
record source query (also try making the name of the text
box bound to that field different than the field name?)

Another thing you can try is to set the Link Master/Child
properties to "", before setting them to what they should
be.
thanks a lot. I set the link fields to "" and deleted the fields. I put
them in again with different names and set the links again. Bingo!

Thanks again. That problem was really bugging me.

Appreciate the help.
 

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