DOSPLUS
New member
- Local time
- Today, 12:00
- Joined
- Oct 28, 2023
- Messages
- 27
HI Guys, I have been on this for a week now and cannot even see what I did wrong cause i am so close to it. In order to simplify things I did not include all the code as it is too big. Here we go...
I got a function that is called from a form, lets say FORM1. As follow:
fncFilter(Forms!Frm_asset, Forms!Frm_asset!SubFrmSOW)
I was expecting that the form and the subform would be passed in order to be used within the scope of the function. Now, the function itself has the following code...
So, the problem I have is that it fails to recognize the targetSubForm as a value to get to. In this case I am referring to a control found on another form that is opened, known as FORM 2.
Known things...
1 - When placing a MsgBox with the targetSubForm string in it. The result is the right value: SubFrmSOW
2 - If i replace the targetSubForm from the function for the value i m trying to pass, in this case it is SubFrmSOW, it works perfectly as intended.
3 - The error I receive is that targetSubForm cannot be found?? Why is it the good value in MsgBox and not in the other spot?
4 - Tried to set as Object, as Form, as SubForm, as String, As Control, nothing worked.
5 - Also tried to Set the variable before using it, and its not any better.
So, everything seemd to be pulled right, but somehow the function does not convert the targetSubForm to its appropriate value.
Could it be because it is part of this type of call:
The intended end result is:
Which confirms that the form is properly passed, but the control somehow is not viewed as it should.. As epxlained above, it works if i am not using the passed ref.
Any help would be appriciated...
I got a function that is called from a form, lets say FORM1. As follow:
fncFilter(Forms!Frm_asset, Forms!Frm_asset!SubFrmSOW)
I was expecting that the form and the subform would be passed in order to be used within the scope of the function. Now, the function itself has the following code...
Code:
Public Function fncFilter(Optional targetForm As Form, Optional targetSubForm As Control)
' Apply the selected filter
With Forms(targetForm.Name)!targetSubForm.Form
.Filter = strReturn
.FilterOn = True
End With
End Function
So, the problem I have is that it fails to recognize the targetSubForm as a value to get to. In this case I am referring to a control found on another form that is opened, known as FORM 2.
Known things...
1 - When placing a MsgBox with the targetSubForm string in it. The result is the right value: SubFrmSOW
2 - If i replace the targetSubForm from the function for the value i m trying to pass, in this case it is SubFrmSOW, it works perfectly as intended.
3 - The error I receive is that targetSubForm cannot be found?? Why is it the good value in MsgBox and not in the other spot?
4 - Tried to set as Object, as Form, as SubForm, as String, As Control, nothing worked.
5 - Also tried to Set the variable before using it, and its not any better.
So, everything seemd to be pulled right, but somehow the function does not convert the targetSubForm to its appropriate value.
Could it be because it is part of this type of call:
Code:
Forms(targetForm.Name)!targetSubForm.Form
The intended end result is:
Code:
Forms(Frm_asset)!SubFrmSOW.Form
' Also works if I put:
Forms(targetForm.Name)!SubFrmSOW.Form
Which confirms that the form is properly passed, but the control somehow is not viewed as it should.. As epxlained above, it works if i am not using the passed ref.
Any help would be appriciated...
Last edited: