Form name to filter = frmSortFor
Filter based on list box from frmTest= lstSortFor
Form containing list box = frmTest
Field (CompCodes) data format = "PM SM TS EW WA"
I have a database that I want to filter a form (frmSortFor) useing the field (CompCodes). I need to find the records that match any of the 2 letter codes that I select on the list box. When i use the code listed below i get an runtime error :
"Microsoft Access can't Find the field 'FrmSortFor' referred to in your expression.".
I am pretty sure it is the way I have my filter syntax is set up but have not been able to find a good example as to what it should look like. Currently the filter data that is generated by the code and is stored in the variable SortFor looks like this:
""Forms!FrmSort For!CompCodes= Like "*5M*" or Forms!FrmSortFo r!CompCodes= Like "*HW*" or Forms!FrmSortFo r!CompCodes= Like "*QM*""
Form name to filter = frmSortFor
Filter based on list box name = lstSortFor
Form containing list box = frmTest
Field (CompCodes) data format = "PM SM TS EW WA"
Current Software
- Access 97
- Win XP
Database
Format of Data in [CompCodes] field "PM SM TS EW WA"
Private Sub cmdPullFiltered Records_Click()
Dim SortFor As String
Dim F As Variant
' Build Criteria string from selected Items in list box
SortFor = ""
For Each F In Me![lstSortFor].ItemsSelected
If SortFor <> "" Then
SortFor = SortFor & " or "
End If
SortFor = SortFor & "Forms!FrmSortF or!CompCodes=" & " Like " & Chr(34) & "*" & Me![lstSortFor].ItemData(F) & "*" & Chr(34)
Next F
' Open and Filter a form based on [CompCodes] field in frmSort for
DoCmd.OpenForm "frmSortFor ", acFormDS
Form!FrmSortFor .Filter = SortFor
Form!FrmSortFor .FilterOn = True
End Sub
Any help would be greatly appretiated. Thank you
Filter based on list box from frmTest= lstSortFor
Form containing list box = frmTest
Field (CompCodes) data format = "PM SM TS EW WA"
I have a database that I want to filter a form (frmSortFor) useing the field (CompCodes). I need to find the records that match any of the 2 letter codes that I select on the list box. When i use the code listed below i get an runtime error :
"Microsoft Access can't Find the field 'FrmSortFor' referred to in your expression.".
I am pretty sure it is the way I have my filter syntax is set up but have not been able to find a good example as to what it should look like. Currently the filter data that is generated by the code and is stored in the variable SortFor looks like this:
""Forms!FrmSort For!CompCodes= Like "*5M*" or Forms!FrmSortFo r!CompCodes= Like "*HW*" or Forms!FrmSortFo r!CompCodes= Like "*QM*""
Form name to filter = frmSortFor
Filter based on list box name = lstSortFor
Form containing list box = frmTest
Field (CompCodes) data format = "PM SM TS EW WA"
Current Software
- Access 97
- Win XP
Database
Format of Data in [CompCodes] field "PM SM TS EW WA"
Private Sub cmdPullFiltered Records_Click()
Dim SortFor As String
Dim F As Variant
' Build Criteria string from selected Items in list box
SortFor = ""
For Each F In Me![lstSortFor].ItemsSelected
If SortFor <> "" Then
SortFor = SortFor & " or "
End If
SortFor = SortFor & "Forms!FrmSortF or!CompCodes=" & " Like " & Chr(34) & "*" & Me![lstSortFor].ItemData(F) & "*" & Chr(34)
Next F
' Open and Filter a form based on [CompCodes] field in frmSort for
DoCmd.OpenForm "frmSortFor ", acFormDS
Form!FrmSortFor .Filter = SortFor
Form!FrmSortFor .FilterOn = True
End Sub
Any help would be greatly appretiated. Thank you
Comment