Hi All
I am trying to apply a filter to a subform using the text filter Like "*text*" by setting up a dynamic SQL query for the subform, see code. The issue I have is that the SQL doesn't seem to apply to the form because it isn't filtering the form.
I have this working fine in a 2010 database using the DoCmd.ApplyFilter method, but need to set up a similar database using 2003 and DoCmd.ApplyFilter doesn't work with subforms and I can't figure out why this code isn't working.
All suggestions welcomed
Thanks
Dave
I am trying to apply a filter to a subform using the text filter Like "*text*" by setting up a dynamic SQL query for the subform, see code. The issue I have is that the SQL doesn't seem to apply to the form because it isn't filtering the form.
Code:
If Not IsNull(Me.ID) Then
pubRecCountPubs = 0
Dim strSQL, strSelectText, strWhereText, strOrderText, strFilterText, strAuthorText As String
strAuthorText = Me.Surname & " " & Left$(Me.Initials, 1)
strFilterText = "(((Authors) Like " & Chr(34) & "*" & Me.Surname & " " & Left$(Me.Initials, 1) & "*" & Chr(34) & "))"
strSelectText = "SELECT Publications.* FROM Publications "
strWhereText = "WHERE " & strFilterText & " "
strOrderText = "ORDER BY Publications.PubYear DESC;"
strSQL = strSelectText & strWhereText & strOrderText
MsgBox strSQL, vbOKOnly, "DEBUG"
Me!PublicationsList.Form.RecordSource = strSQL
Me.PublicationsList.Form.Refresh
End If
I have this working fine in a 2010 database using the DoCmd.ApplyFilter method, but need to set up a similar database using 2003 and DoCmd.ApplyFilter doesn't work with subforms and I can't figure out why this code isn't working.
All suggestions welcomed
Thanks
Dave