Hi all,
I have a main form (BrianMainForm) and it has a subform (BrianSubform). Their recordsources are the same. I wanted to arrange things so that when I apply a filter to BrianMainForm, the filter also gets applied to BrianSubform.
I put the following code in the "Form_Applyfilter" procedure of BrianMainForm:
Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
Me![BrianSubform].Form.Filter = Me.Filter
End Sub
If I right-click any field/textbox on BrianMainForm to get the pop-up menu and I then enter a string in the "Filter For:" box and press return, the filter gets applied (as intended) to both BrianMainForm and BrianSubform. It works every time!! When I first saw this I thought "yippppeee, success, how cool...."!!!!! But my elation was short-lived.
I now wanted to do something slightly differently; instead of right-clicking and using the pop-up menu to filter BrianMainForm, I tried using "Filter By Form". I entered the filter criteria and then, when I pressed the "Apply Filter" button, I got the following message:
Run-time Error '2448':
You can't assign a value to this object.
*The object may be a control on a read-only form.
*The object may be on a form that is open in Design view.
*The value may be too large for this field.
When I choose to Debug, I find the sticking point is at the third line of my routine, i.e. at:
"Me![BrianSubform].Form.Filter = Me.Filter"
Why should this code fail to work just because I applied the filter to BrianMainform in a different way? Could someone please suggest where I'm going wrong?
Thanks,
Brian
I have a main form (BrianMainForm) and it has a subform (BrianSubform). Their recordsources are the same. I wanted to arrange things so that when I apply a filter to BrianMainForm, the filter also gets applied to BrianSubform.
I put the following code in the "Form_Applyfilter" procedure of BrianMainForm:
Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
Me![BrianSubform].Form.Filter = Me.Filter
End Sub
If I right-click any field/textbox on BrianMainForm to get the pop-up menu and I then enter a string in the "Filter For:" box and press return, the filter gets applied (as intended) to both BrianMainForm and BrianSubform. It works every time!! When I first saw this I thought "yippppeee, success, how cool...."!!!!! But my elation was short-lived.
I now wanted to do something slightly differently; instead of right-clicking and using the pop-up menu to filter BrianMainForm, I tried using "Filter By Form". I entered the filter criteria and then, when I pressed the "Apply Filter" button, I got the following message:
Run-time Error '2448':
You can't assign a value to this object.
*The object may be a control on a read-only form.
*The object may be on a form that is open in Design view.
*The value may be too large for this field.
When I choose to Debug, I find the sticking point is at the third line of my routine, i.e. at:
"Me![BrianSubform].Form.Filter = Me.Filter"
Why should this code fail to work just because I applied the filter to BrianMainform in a different way? Could someone please suggest where I'm going wrong?
Thanks,
Brian