Data not being recognized in Dataset???

gblack

Registered User.
Local time
Today, 22:30
Joined
Sep 18, 2002
Messages
632
So I am trying to pull some title information to update a couple fields in on of my tables, but when I try to create a dataset, Access seems to think there is not data (it tells me either BOR or EOF is true, when I try to rs.MoveFirst). I have also tried to do a record count (i.e., If rs.recordcount > 0 Then...), but that also evaluates my strSQL as having no records...

But in my watch window I can copy the variable strSQL and dump that into a new query and it shows 105 records. So why does Access keep telling me there are no records?

Here's my code:

Code:
    Dim db As Database
    Dim strSQL, strCheck, strOptionalIDCheck As String
    Dim intTemplateType As Integer
    Dim rs As ADODB.Recordset
    
    '----------------------------------------------------------------------------------------------------------------------
    ' This function will denote the level of SAMS Prvileges. By Division.
    '----------------------------------------------------------------------------------------------------------------------
    Set db = CurrentDb
    
    Set rs = New ADODB.Recordset
    strSQL = "SELECT Services_Title, Optional_Indentifier From AGREEMENT " & _
             "WHERE (Services_Title Like " & Chr(34) & Chr(42) & "MASTER" & Chr(42) & Chr(34) & " " & _
             "OR Services_Title Like " & Chr(34) & Chr(42) & "Template" & Chr(42) & Chr(34) & ") ;"
    With rs
        .ActiveConnection = CurrentProject.Connection
        .CursorType = adOpenKeyset
        .LockType = adLockOptimistic
        .Open (strSQL)
    End With
    
    If Not (rs.BOF And rs.EOF) Then... 'do Something

What am i doing wrong here?
 
I believe your wild card character needs to be a % instead of an asterisk (when using ADO). That might be the problem.
 
Yep that did the trick...


Thanks for your help Sir!
 

Users who are viewing this thread

Back
Top Bottom