hi guys, im having some trouble here and cant figure out what im doing wrong.
i have a vb6 program linked to a ms database and im running queries and returing the results in a listbox on the same form. here is what i have:
Private Sub cmdSearchauthor_Click() Dim strSearchFor As String, foundFlag As Boolean 'Search for the Author specified by the user strSearchFor = UCase(InputBox("Enter the Author to find:")) If Len(strSearchFor) > 0 Then datBooks.Recordset.MoveFirst foundFlag = False Do While (Not foundFlag) And (Not datBooks.Recordset.EOF) If UCase(datBooks.Recordset.Fields("Author").Value) = strSearchFor Then foundFlag = True lstBooks.AddItem datBooks.Recordset.Fields("Title").Value Else datBooks.Recordset.MoveNext End If Loop If Not foundFlag Then MsgBox "Unable to locate requested Author.", , "Not Found" datBooks.Recordset.MoveLast 'move so that EOF is no longer true End If Else MsgBox "Must enter an Author.", , "" End If End Sub
when i run this query i want it to return all of the book titles written by a certain author in the database, this query works but only returns one of the book titles by the author instead of all of them. i think there may be something wrong with my loop or something but i cant see it
can someone please tell me where im going wrong?
thanks in advance guys