Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 19th, 2004, 11:11 AM
Registered User
 
Join Date: Aug 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default EOF always false with wildcard

I am having a problem with a recordset. When I do a query that uses the LIKE operator and the % wildcard, then cycle through the resulting recordset to add the records to a list box, EOF never becomes true. It will add the records, but never reach EOF. If I don't use the LIKE operator with the wildcard, it cycles through the recordset just fine and ends. What is going on?

Here is the code:
'Declare cnnGetHits
Dim cnnGetHits As ADODB.Connection
'Declare rstGetHits
Dim rstGetHits As ADODB.Recordset

'Set cnnGetHits to a new connection
Set cnnGetHits = New ADODB.Connection
'Set rstGetHits to a new recordset
Set rstGetHits = New ADODB.Recordset

'Create the SQL statement
'SQL = "SELECT * FROM tblAttenders " & _
      "WHERE Ucase$(LastName) like '" & strLastName & "%'"

'Open cnnGetHits
cnnGetHits.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='c:\church.mdb'"
'Open rstGetHits
rstGetHits.Open SQL, cnnGetHits, adOpenKeyset, adLockOptimistic

with rstGetHits

    'Move to the first record
    .MoveFirst

    'Loop through the record
    Do Until .EOF

        'Add the item
        lstHits.AddItem !LastName & " " & !FirstName

        'Move to the next record
        .MoveNext

    Loop

End With
 
Old August 20th, 2004, 12:44 AM
Authorized User
 
Join Date: Feb 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
Try to change this part


Do While not rstGetHits.EOF


    'Loop through the record

        'Add the item
        lstHits.AddItem !LastName & " " & !FirstName

    'Move to the next record
    rstGetHits.MoveNext

Loop

End With





Similar Threads
Thread Thread Starter Forum Replies Last Post
matrix multiplication using wildcard in C/C++ rubnrj C++ Programming 0 March 5th, 2008 03:10 AM
Wildcard on nText field rit01 SQL Server 2000 1 March 17th, 2006 12:48 PM
rs.eof returns false hastikeyvan Dreamweaver (all versions) 3 February 4th, 2006 11:08 AM
Sproc not Working with WildCard [email protected] SQL Server 2000 7 July 15th, 2005 05:38 AM
select wildcard element names groovepapa XSLT 4 September 1st, 2004 08:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.