Will below do?
Thanks
Regards
Function DLookup(ByVal SearchFld As String, ByVal SearchTbl As String, ByVal
SearchCriteria As String) As Object
Dim Cmd As OleDb.OleDbCommand
Dim Reader As OleDb.OleDbDataReader
Dim Value As Object = DBNull.Value
DLookup = Nothing
Cmd = New OleDb.OleDbCommand("SELECT " & SearchFld & " FROM " & SearchTbl &
" WHERE " & SearchCriteria, DBConnection())
Reader = Cmd.ExecuteReader()
If Microsoft.VisualBasic.Left(SearchFld, 1) = "[" Then
SearchFld = Microsoft.VisualBasic.Right(SearchFld,
Microsoft.VisualBasic.Len(SearchFld) - 1)
End If
If Microsoft.VisualBasic.Right(SearchFld, 1) = "]" Then
SearchFld = Microsoft.VisualBasic.Left(SearchFld,
Microsoft.VisualBasic.Len(SearchFld) - 1)
End If
If (Reader.Read()) Then
Value = IIf(Reader.GetString(Reader.GetOrdinal(SearchFld)) Is Nothing, "",
Reader.GetString(Reader.GetOrdinal(SearchFld)))
End If
DLookup = Value
End Function
"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0. 1...
"John" <Jo**@nospam.infovis.co.ukwrote in news:ezmv58hgIHA.5160
@TK2MSFTNGP05.phx.gbl:
>What is a fast way to do this? Sorry, but too many answers is no answer.
What's your data source?
If it's a database, use a SQL Query.
--
sp**********@rogers.com (Do not e-mail)