Situation:
I've got a main form, ScriptCreator, with two separate continuous sub-forms, ScriptCreatorSu b and ScriptCreatorCu rrentScript.
The idea is that the ScriptCreatorSu b form displays all the options you can pick from, and each row has a 'Select' button next to it. When you click the Select button, the row of data is copied to a new table, called TestsForScripts , via an append query. This table is linked to the second continuous subform, ScriptCreatorCu rrentScript. This second subform queries the table and pulls through any items already 'selected' concerning the current script.
So in short, you've got a form of options, and a form showing what you've already picked.
(Before anyone asks, I know that data duplication goes against database structure standards, but the use of the database and the manipulation of data after 'selection' means that data duplication is required, as opposed to just referencing the original table.)
All of this works fine, however what I'm now trying to implement a way of hiding/filtering out the items from the original list that have already been selected.
So for example say I've got Items A through to Z in ScriptCreatorSu b. If I pick Item M, Item M appears in ScriptCreatorCu rrentScript, and ScriptCreatorSu b now only offers a list of Items A-L, N-Z.
I already have a system in place to filter the list on ScriptCreatorSu b, which is based around the NeoPa's code example on this forum. I've tried adding in extra coding in the RunFilter process, but it just returns an error of:
Run-time error '2427':
You entered an expression that has no value.
This is the code I'm using for the filters, as I would have thought this is where I can apply new code to achieve what I'm after:
It's this part that I've added in the above code (near the bottom) which gives the error:
If anyone can offer any help, it would be much appreciated! This forum has so far yet to fail on pointing out an obvious answer to my problems! :)
Thanks.
I've got a main form, ScriptCreator, with two separate continuous sub-forms, ScriptCreatorSu b and ScriptCreatorCu rrentScript.
The idea is that the ScriptCreatorSu b form displays all the options you can pick from, and each row has a 'Select' button next to it. When you click the Select button, the row of data is copied to a new table, called TestsForScripts , via an append query. This table is linked to the second continuous subform, ScriptCreatorCu rrentScript. This second subform queries the table and pulls through any items already 'selected' concerning the current script.
So in short, you've got a form of options, and a form showing what you've already picked.
(Before anyone asks, I know that data duplication goes against database structure standards, but the use of the database and the manipulation of data after 'selection' means that data duplication is required, as opposed to just referencing the original table.)
All of this works fine, however what I'm now trying to implement a way of hiding/filtering out the items from the original list that have already been selected.
So for example say I've got Items A through to Z in ScriptCreatorSu b. If I pick Item M, Item M appears in ScriptCreatorCu rrentScript, and ScriptCreatorSu b now only offers a list of Items A-L, N-Z.
I already have a system in place to filter the list on ScriptCreatorSu b, which is based around the NeoPa's code example on this forum. I've tried adding in extra coding in the RunFilter process, but it just returns an error of:
Run-time error '2427':
You entered an expression that has no value.
This is the code I'm using for the filters, as I would have thought this is where I can apply new code to achieve what I'm after:
Code:
Private Sub RunFilter()
Dim strFilter As String, strOldFilter As String
'CheckFilter produces the new Filter depending on the values currently in
'the various filter boxes.
strOldFilter = Me.Filter
'FilterRef_ID - Numeric
If Me!FilterRef_ID > "" Then _
strFilter = strFilter & _
" AND ([Ref_ID]=" & _
Me!FilterRef_ID & ")"
'FilterPageTitle - Text
If Me!FilterPageTitle > "" Then _
strFilter = strFilter & _
" AND ([PageTitle] Like '*" & _
Me!FilterPageTitle & "*')"
'FilterPageAddress - Text
If Me!FilterPageAddress > "" Then _
strFilter = strFilter & _
" AND ([PageAddress] Like '*" & _
Me!FilterPageAddress & "*')"
'FilterFieldElement - Text
If Me!FilterFieldElement > "" Then _
strFilter = strFilter & _
" AND ([Field/Element] Like '*" & _
Me!FilterFieldElement & "*')"
'FilterTestFor - Text
If Me!FilterTestFor > "" Then _
strFilter = strFilter & _
" AND ([TestFor] Like '*" & _
Me!FilterTestFor & "*')"
'FilterType - Text
If Me!FilterType > "" Then _
strFilter = strFilter & _
" AND ([TypeOfTest] Like '" & _
Me!FilterType & "*')"
'FilterPriority - Text
If Me!FilterPriority > "" Then _
strFilter = strFilter & _
" AND ([Priority] Like '" & _
Me!FilterPriority & "*')"
strFilter = strFilter & _
" AND ([Ref_ID]<>" & _
Forms![ScriptCreator]![ScriptCreatorCurrentScript]![Ref_ID]
'Debug.Print ".Filter = '" & strOldFilter & "' - ";
'Debug.Print "strFilter = '" & strFilter & " '"
'Tidy up results and apply IF NECESSARY
If strFilter > "" Then strFilter = Mid(strFilter, 6)
If strFilter <> strOldFilter Then
Me.Filter = strFilter
End If
Me.FilterOn = (strFilter > "")
End Sub
Code:
strFilter = strFilter & _
" AND ([Ref_ID]<>" & _
Forms![ScriptCreator]![ScriptCreatorCurrentScript]![Ref_ID]
Thanks.
Comment