Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 183
  • Last Modified:

ADO RecordSet by Writing the WHERE cluase for a Part of a field it dos not work for me

I Am Using MS Access 2003 SP1
and ADO 2.7 library

Dim CN As New ADODB.Connection
   Set CN = New ADODB.Connection
   CN.CursorLocation = adUseClient
   CN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & App.Path & "\data.mdb; Persist Security Info=False"
   CN.Mode = adModeReadWrite
   CN.Open

Dim RS As New ADODB.Recordset, SqlSql As String
   
    SqlSql = "SELECT [LastName] & ' ' & [FirstName]  AS Name1 FROM ListNames WHERE ListNames.LastName LIKE '*p*'"
    If RS.State = adStateOpen Then Set RS = Nothing
  RS.CursorLocation = adUseClient
  RS.Open SqlSql, CN, adOpenKeyset, adLockPessimistic, adCmdText
If RS.EOF And RS.BOF Then
        MsgBox "There are no records in the List or Selection", vbCritical, TovTtl
Else
        MsgBox RS!Name1
End If

i have many fields with the letter P in it, and my recordset dos not find it
I experimented, and it appears that the wildcard does not work in my recordset.

Does anyone know a way around this?

Thanks!!
0
YomTovSuccos
Asked:
YomTovSuccos
1 Solution
 
Faheem ShaikhCommented:
instead of this::
ListNames.LastName LIKE '*p*'

Try this::
ListNames.LastName LIKE '%p%'

Good luck
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now