How to avoid Runtime error 2101 - The setting you entered in not valid for this property - Access

Hi,
  While trying to assign LinkMasterFields or LinkChildFields property in Access project file, I get the below error

"Runtime error 2101 - The setting you entered in not valid for this property"

I am trying to link the combobox  value to a pivot chart.

Eg:
LinkMasterFields = "cboEmployee"
LinkChildFields = "Empl_Id"

cboEmployee combo lists all employees from Employee table + "ALL' to cancel the filter...

So, at runtime, I am assigning the pivot chart source object + the links
If cboEmployee.value = 0 (means "ALL") then
LinkMasterFields = ""
LinkChildFields = ""
Else
LinkMasterFields = "cboEmployee"
LinkChildFields = "Empl_Id"

What could be the cause and how to avoid the above error?
xsysysAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

milduraitCommented:
Possibly the value of cboEmployee is null and is not of integer type.
If NZ(cboEmployee.value,0) = 0 then
   LinkMasterFields = ""
   LinkChildFields = ""
Else
   LinkMasterFields = "cboEmployee"
   LinkChildFields = "Empl_Id
End If

Open in new window

xsysysAuthor Commented:
cboEmployee always returns a valid value (0 or selected employee empl_id)..
The above error occurs in the line
subform_control.linkMasterFields = "" or subform_control.LinkChildFields = "" or
subform_control.linkMasterFields = "cboEmployee" or
subform_control.linkChildFields = "Empl_Id"
milduraitCommented:
Maybe giveup on the idea of trying to set the linkMasterfields and linkChildfields and try something else that mimics the same behaviour.  

You could try something like below, where frmOne is the name of the parent form.
Private Sub cboEmployee_AfterUpdate()
    Me.subform_control.Form.Filter = "Field1=" & [Forms]!frmOne.cboEmployee.Value
    Me.subform_control.Form.FilterOn = True
    Me.subform_control.Form.txtFKey.DefaultValue = [Forms]!frmOne.cboEmployee.Value
 
End Sub

Open in new window

milduraitCommented:
Let me try again.
Private Sub cboEmployee_AfterUpdate()
    Me.subform_control.Form.Filter = "Empl_Id=" & [Forms]!frmOne.cboEmployee.Value
    Me.subform_control.Form.FilterOn = True
    Me.subform_control.Form.txtFKey.DefaultValue = [Forms]!frmOne.cboEmployee.Value
End Sub

Open in new window

xsysysAuthor Commented:
I have not done anything...After a while it started working without any change.  The maximum thing which I could try is
Compact and Repair database + decompile the .adp file
 
 

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.