Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with RecordCount

Status
Not open for further replies.

rickgalty

Programmer
Nov 10, 2005
32
US
Hello again, everyone. Can someone please tell me what I'm doing wrong again?

In my app, the user can put in part of the name of a training class to see records. If the database doesn't find a match, or only matches one class to the search criteria, fine, but if it matches more than one, I want to display a list of the matching classes for the user to click on. Here's the code where this is failing...

If optTraining = True Then

Set rs = db.OpenRecordset("SELECT CourseNum, Training FROM Training WHERE Training like '" & txtListBy.Text & "*" & "'")

If rs.RecordCount > 0 Then

If rs.RecordCount > 1 Then
lstTypes.Visible = True
While Not rs.EOF
lstTypes.AddItem rs!Training
rs.MoveNext
Wend
End If

Text1.Text = rs.RecordCount

I put the "text1.text = rs.RecordCount" to see what's going on. However many records are returned, it always shows '1'. BUT.... If I change the second "if" to also read "If rs.RecordCount > 0 Then" (Instad of >1) then the list box becomes visible, and the rs.recordcount value reflects the real recordcount.

What is wrong please?

Richard
 


Hi,

Code:
rs.movelast
if rs.recordcount....


Skip,

[glasses] [red]Be Advised![/red]
The band of elderly oriental musicians, known as Ground Cover, is, in reality...
Asian Jasmine![tongue]
 
Thanks, didn't realise I had to go through the recordset to get the recordcount.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top