Randomblink
The Irreverent Reverend
- Local time
- Today, 06:46
- Joined
- Jul 23, 2001
- Messages
- 279
Public Function lstSearcher(fldSelect As String, tblFrom As String, fldWhere As String, txtIsLike As TextBox, lstFindHere As ListBox)
Dim db As DAO.Database, rs As DAO.Recordset, strSQL As String
Set db = CurrentDb
strSQL = "SELECT " & fldSelect & " FROM " & tblFrom & " WHERE " & fldWhere & " LIKE '" & txtIsLike.Text & "*'"
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
If rs.RecordCount > 0 Then
rs.MoveFirst
lstFindHere = rs!fldSelect
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Function
I want to call this function, but the last line rs!fldSelect ain't working...
If I call this like so:
lstSearcher "SkID", "tbkSkills", "SkName", txtSearch, lstAllSkills
Then the function runs, but I end up finding no records and the rs!fldSelect line is lit up in VBE...
What am I doing wrong...?
Dim db As DAO.Database, rs As DAO.Recordset, strSQL As String
Set db = CurrentDb
strSQL = "SELECT " & fldSelect & " FROM " & tblFrom & " WHERE " & fldWhere & " LIKE '" & txtIsLike.Text & "*'"
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
If rs.RecordCount > 0 Then
rs.MoveFirst
lstFindHere = rs!fldSelect
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Function
I want to call this function, but the last line rs!fldSelect ain't working...
If I call this like so:
lstSearcher "SkID", "tbkSkills", "SkName", txtSearch, lstAllSkills
Then the function runs, but I end up finding no records and the rs!fldSelect line is lit up in VBE...
What am I doing wrong...?