jesse-jordan
04-13-2004, 11:56 AM
I want to search my access database in vb. I need it to search and then put the results into a list box with two columns. I'm not allowed to use sql though, I am really stuck can anyone help! It is probably really simple.
Thanks
Jesse
Heres the code I use at the minute to search:
Private Sub cmdSearch_Click()
Dim strSearchFor As String, FoundFlag As Boolean
strSearchFor = InputBox("Enter Students Name:")
Data1.Recordset.MoveFirst
FoundFlag = False
While (Not FoundFlag) And (Not Data1.Recordset.EOF)
If Data1.Recordset.Fields("StudentName").Value = strSearchFor Then
FoundFlag = True
Else
Data1.Recordset.MoveNext
End If
Wend
If FoundFlag Then
MsgBox "Found It!"
Else
MsgBox "Sorry"
End If
End Sub
Thanks
Jesse
Heres the code I use at the minute to search:
Private Sub cmdSearch_Click()
Dim strSearchFor As String, FoundFlag As Boolean
strSearchFor = InputBox("Enter Students Name:")
Data1.Recordset.MoveFirst
FoundFlag = False
While (Not FoundFlag) And (Not Data1.Recordset.EOF)
If Data1.Recordset.Fields("StudentName").Value = strSearchFor Then
FoundFlag = True
Else
Data1.Recordset.MoveNext
End If
Wend
If FoundFlag Then
MsgBox "Found It!"
Else
MsgBox "Sorry"
End If
End Sub