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

xsysys
xsysys used Ask the Experts™
on
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?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
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

Author

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"
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

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

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
 
 

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial