Search Field for my listbox (1 Viewer)

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

Tim K.

Registered User.
Local time
Today, 12:46
Joined
Aug 1, 2002
Messages
242
Change this portion below to this.

...
rs.MoveFirst
lstFindHere = rs(fldSelect)
End If
...
 

Randomblink

The Irreverent Reverend
Local time
Today, 06:46
Joined
Jul 23, 2001
Messages
279
Actually...

What I found to work for me...
Was:

rs.Fields(fldSelect)

Thanks for the assist tho, that was driving me nuts...
 

Users who are viewing this thread

Top Bottom