linkmastrerfields and linkchildfields must be same number of field

D

DavidAtCaspian

This one caused me a few problems.

I have a form /subform where sometimes I want to link by Surname alone, and
sometimes by Surname AND first name. The difference is selected by command
button.

BUT every time I change, as soon as it get to the first one, up comes a
message saying that both links must be the same number of fields.
The error comes up before it gets to the second line, which does indeed have
the same number of fields as the first.

The solution, (which I haven't seen on the boards) is to repeat line 1 in
postions 3, and put in an error trap that simply says Resume Next.
Up comes the error. Resume next ignores the error line and runs the second
line (which records that both links have the same number of records). and the
third line implements what the first one couldn't.

Not sure if Microsoft would regard this as a bug or not. But it does the job.

Example:

Private Sub cmdFindByName_Click()
On Error GoTo Trap:
Me.subUnMatchedWGHEpisodes.LinkMasterFields = "Surname"
Me.subUnMatchedWGHEpisodes.LinkChildFields = "Surname"
Me.subUnMatchedWGHEpisodes.LinkMasterFields = "Surname"

Exit Sub

Trap:
Resume Next

End Sub
__________________________________________________
Private Sub cmdFullName_Click()

On Error GoTo Trap:

Me.subUnMatchedWGHEpisodes.LinkMasterFields = "Surname,Forename"
Me.subUnMatchedWGHEpisodes.LinkChildFields = "Surname,Forename"
Me.subUnMatchedWGHEpisodes.LinkMasterFields = "Surname,Forename"


Trap:
Resume Next


End Sub
 
M

Marshall Barton

DavidAtCaspian said:
This one caused me a few problems.

I have a form /subform where sometimes I want to link by Surname alone, and
sometimes by Surname AND first name. The difference is selected by command
button.

BUT every time I change, as soon as it get to the first one, up comes a
message saying that both links must be the same number of fields.
The error comes up before it gets to the second line, which does indeed have
the same number of fields as the first.

The solution, (which I haven't seen on the boards) is to repeat line 1 in
postions 3, and put in an error trap that simply says Resume Next.
Up comes the error. Resume next ignores the error line and runs the second
line (which records that both links have the same number of records). and the
third line implements what the first one couldn't.

Not sure if Microsoft would regard this as a bug or not. But it does the job.


That is a tricky situation. I haven't done this in a long
time, but I seem to remember that the trick was to set
LinkChild before LinkMaster. Or maybe it was to set the
properties to a zero length string first??
 
D

DavidAtCaspian

Thanks Marsh:

It's nothing to do with which one is set first (tried that one en route :)).

But, I WILL look at your other suggestion: Taking advantage of system
generated errors feel a bit like cheating. (The half brick approach - crude
but effective)


David
 

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