Trying to use Like * at the end

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have this on a form called "frmInQuiry".

It is a text box and I would like to Filter out the data but this only works
if account = AccSer. How can I put a wild card(*) at the end in the text box
called AccSer.

The person does not need to know the whole Account.

Private Sub AccSer_LostFocus()
Dim strFilter As String

strFilter = ""

FilterOn = True



If Not IsNull(Forms!frmInQuiry.AccSer) Then
If strFilter = "" Then
'strFilter = "Forms!frmInquiry.Account = Forms!frmInquiry.AccSer"
strFilter = "Account = forms!frmInquiry.AccSer"
Else
strFilter = strFilter & " and Account = Forms!frmInquiry.AccSer"
End If
End If

Me.Filter = strFilter

Requery
End Sub

Thank you in advance for any help
 
hi,
I have this on a form called "frmInQuiry".
It is a text box and I would like to Filter out the data but this only works
if account = AccSer. How can I put a wild card(*) at the end in the text box
called AccSer.
The person does not need to know the whole Account.
Private Sub AccSer_LostFocus()
Dim strFilter As String

strFilter = ""
FilterOn = True
If Not IsNull(Forms!frmInQuiry.AccSer) Then
If strFilter = "" Then
'strFilter = "Forms!frmInquiry.Account = Forms!frmInquiry.AccSer"
strFilter = "Account = forms!frmInquiry.AccSer"
Else
strFilter = strFilter & " and Account = Forms!frmInquiry.AccSer"
End If
End If

Me.Filter = strFilter

Requery
End Sub
This can be improved in some ways:

Private Sub AccSer_LostFocus()

Dim strFilter As String

strFilter = ""
If Not IsNull(AccSer) Then
strFilter = "Account LIKE '" & Replace(AccSer, "'", "''") & "*'"
End If

Me.Filter = strFilter
Me.FilterOn = True

End Sub



mfG
--> stefan <--
 
Back
Top