Chris
Chris

Reputation: 67

Searching a name in a subform table via vba using combo box

I am trying to make a search filter for names on a subform from a parent form using a combo box, I already managed to do it searching dates, Im trying to do it depending on a client name now... I have, but it doesnt work...

    Me.subform.Form.Filter = "[Client]=& me.cboClientName&"

I manage to do the search by dates instruction like this....

    Me.subform.Form.Filter = "[AppointDate]=#" & Format(Me.cbSelectDate, "yyyy-mm-dd") & "#"

Upvotes: 0

Views: 153

Answers (1)

BitAccesser
BitAccesser

Reputation: 719

You have to concat the string with the searched column and the value of the combobox and you have to apply the filter.

Dim strFilter as string

'first print what you did
strFilter =  "[Client]=& me.cboClientName&"
Debug.Print "Your faulty filter: " & strFilter ' shown in immediate window

'now with concat
strFilter = "[Client]= '" & Me.cboClientName & "'" ' suround by quotes because I assume it's a string
Debug.Print "filter: " & strFilter

Me.subform.Form.Filter = strFilter
Me.subform.Form.FilterOn = true ' activate the Filter

Upvotes: 1

Related Questions