View Full Version : Filter report by text field wildard - help required


copsy1979
10-02-2008, 03:13 AM
Hi, I have succesfully created reports to be filtered using a date range and a client code but am struggling with the code required to filter by a text field. The process I use is as per "Allen browne" where you create a form to enter the required criteria.

The coding I have in the "preview" button on the form is as follows:

strReport = "rptSalesVolumebyClient"
strField = [CompanyName]
lngView = acViewPreview

If Not IsNull(Me.txtcompanyname) Then 'no name'
strWhere = strField & Like "*" & Format(Me.txtcompanyname,)
End If

I need to be able to enter part of company name so that report will show all branches for a particular company.

Can anyone assist?
Thanks in advance

Rabbie
10-02-2008, 03:35 AM
If it is a text field then you need it in quotes.

Try [code]
strReport = "rptSalesVolumebyClient"
strField = [CompanyName]
lngView = acViewPreview

If Not IsNull(Me.txtcompanyname) Then 'no name'
strWhere = strField & Like "'*" & Me.txtcompanyname & "'"

End If

copsy1979
10-02-2008, 03:41 AM
Hi, tried this but it throws up error message

compile error
syntax error

Any suggestions?