Paul Sansom
Board Regular
- Joined
- Jan 28, 2013
- Messages
- 178
- Office Version
- 2021
- 2016
- Platform
- Windows
Hi I have a sub that is my query filter. It current filters bra on "=" to cell input. I cannot work out the syntax for a "containing" filter e.g contains bra.
I have tried a simple subtituion of = for contains but it does not filter correctly......
'myADO.RunQuery "Select [Photo Number], [Branch Ref], Comments, Place, [Viewing Order], Date, [Source Other Names], [Source Last Name] From [Photos$]" _
& " Where [Branch Ref] contains '" & bra & "'", shResults
Any guidance always gratefully accepted.. Paul
Code shown works well as = string!!!!
I have tried a simple subtituion of = for contains but it does not filter correctly......
'myADO.RunQuery "Select [Photo Number], [Branch Ref], Comments, Place, [Viewing Order], Date, [Source Other Names], [Source Last Name] From [Photos$]" _
& " Where [Branch Ref] contains '" & bra & "'", shResults
Any guidance always gratefully accepted.. Paul
Code shown works well as = string!!!!
VBA Code:
Sub byBranchRef()
' Filter by branch ref
Dim myADO As New clsADO
myADO.Connect ThisWorkbook.FullName
bra = Output.Range("d5")
myADO.RunQuery "Select [Photo Number], [Branch Ref], Comments, Place, [Viewing Order], Date, [Source Other Names], [Source Last Name] From [Photos$]" _
& [B]" Where [Branch Ref] = '" & bra & "'"[/B], shResults
End Sub