• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1335
  • Last Modified:

Link Child/Master run-time error 2335

I am trying to change the Child/Master links in the following manner:

Private Sub Frame23_AfterUpdate()
If Me.Frame23.value = 1 Then
 
  Me("sfrmpayhrs").LinkChildFields = "site_name ; weekno"
  Me("sfrmpayhrs").LinkMasterFields = "site_name ; weekno1"
  Me.sfrmPayHrs.Requery
 
ElseIf Me.Frame23.value = 2 Then

  Me("sfrmpayhrs").LinkChildFields = "site_name ; weekno"
  Me("sfrmpayhrs").LinkMasterFields = "site_name ; weekno2"
  Me.sfrmPayHrs.Requery

ElseIf Me.Frame23.value = 3 Then

  Me("sfrmpayhrs").LinkChildFields = "site_name"
  Me("sfrmpayhrs").LinkMasterFields = "site_name"
  Me.sfrmPayHrs.Requery

End If

End Sub

. . . when I update the control I get :

"run-time error 2335" "You must use the same number of fields when you set the LinkChildFields and LinkMasterFields properties"

How can I get this code to work?

(Acc 2002 Win 2000)

Thanks
0
tonydemarco
Asked:
tonydemarco
1 Solution
 
squirrlCommented:
Is it possible to provide a little more detail?  Are we talking mainform/subform child master links?
0
 
tonydemarcoAuthor Commented:
squirrl,

Yes.
Frame23 is an option box on the main form that after update, resets the subform master/child relations.
I believe that the error occurs because the code tries to reset the links from two relations to one.


0
 
squirrlCommented:
That makes sense.  If you have, for example, a 'Client'
form and subform, they might well be linked on ClientID.  If you let Access do the linking, via the form wizard, that is the sort of thing it comes up with.

squirrl.
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
squirrlCommented:
If you let me know why you want to change the link, it might help in arriving at a solution.  Might you be looking for a tabbed form perhaps?
0
 
tonydemarcoAuthor Commented:
Here is what I did to solve the problem.

In the data table I added a placeholder field with a value of one. Basically a dummy field.

Then I coded as follows:

Private Sub Frame23_AfterUpdate()
If Me.Frame23.value = 1 Then
  Me("sfrmPayHrs").LinkChildFields = "site_name ; weekno"
  Me("sfrmPayHrs").LinkMasterFields = "site_name ; weekno1"
  Me.sfrmPayHrs.Requery
 
ElseIf Me.Frame23.value = 2 Then
  Me("sfrmPayHrs").LinkChildFields = "site_name ; weekno"
  Me("sfrmPayHrs").LinkMasterFields = "site_name ; weekno2"
  Me.sfrmPayHrs.Requery

ElseIf Me.Frame23.value = 3 Then
  Me("sfrmPayHrs").LinkChildFields = "site_name ; placeholder"
  Me("sfrmPayHrs").LinkMasterFields = "site_name ; placeholder"
  Me.sfrmPayHrs.Requery
End If
End Sub

This establishes the same number (2) of links and the form works.

squirrl, thanks for your help.

0
 
OzzModCommented:
Closed, 500 points refunded.
OzzMod
Community Support Moderator (Graveyard shift)
0
 
MzLibertyCommented:
Thanks! You can actually just list the same link field twice when you only want the one field to link. Handy when switching between a filtered view and the entire dataset.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now