N
niuginikiwi
Hi,
I have looked at all the postings concerning the filtering of subforms but
can't find anything close to what I have in question.
I have a criteria form where i seletect multiple values from a listbox and
put it into a IN string and pass this as a filter parameter to the Open form
command that opens another form... I can so far get it to filter if the form
that is opened is bound to some record source which contains the the field
that i use as filter...
But what I want to do is to open that unbound form and filter the subform
(ie in DS view coz I have another subfrom linked to the first subform and
they all on the same unbound form) as soon as I make my selection in the
criteria form and click the command button to open the unbound form that
contains all my subform to be filtered.
Here is the colde that I use on the onClick event of the command button.
Private Sub btnEdit_Click()
On Error GoTo Err_btnEdit_Click
'Variables
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmPlanting"
'Assign filter variable with values selected from listbox
stLinkCriteria = "PlantingID" & MultiSelectSQL(lstOperationsEdit)
'If form is already open close it using the global IsLoaded function
If CurrentProject.AllForms(stDocName).IsLoaded Then
DoCmd.Close , stDocName
End If
'Open the form and apply filter
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_btnEdit_Click:
Exit Sub
Err_btnEdit_Click:
MsgBox Err.Description
Resume Exit_btnEdit_Click
End Sub
Any quick help would be so much appreciated.
I have looked at all the postings concerning the filtering of subforms but
can't find anything close to what I have in question.
I have a criteria form where i seletect multiple values from a listbox and
put it into a IN string and pass this as a filter parameter to the Open form
command that opens another form... I can so far get it to filter if the form
that is opened is bound to some record source which contains the the field
that i use as filter...
But what I want to do is to open that unbound form and filter the subform
(ie in DS view coz I have another subfrom linked to the first subform and
they all on the same unbound form) as soon as I make my selection in the
criteria form and click the command button to open the unbound form that
contains all my subform to be filtered.
Here is the colde that I use on the onClick event of the command button.
Private Sub btnEdit_Click()
On Error GoTo Err_btnEdit_Click
'Variables
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmPlanting"
'Assign filter variable with values selected from listbox
stLinkCriteria = "PlantingID" & MultiSelectSQL(lstOperationsEdit)
'If form is already open close it using the global IsLoaded function
If CurrentProject.AllForms(stDocName).IsLoaded Then
DoCmd.Close , stDocName
End If
'Open the form and apply filter
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_btnEdit_Click:
Exit Sub
Err_btnEdit_Click:
MsgBox Err.Description
Resume Exit_btnEdit_Click
End Sub
Any quick help would be so much appreciated.