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
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