hi
ive got a problem with a search function
it only seems to work with constants not with variables
ive tried to use the field and criteria as a constant and table as var this works
but i need all of them as a var
im using Access 2002 / XP with VBA 6.3 and MS DAO 3.51 Object Library
Function Find()
Dim Table As String
Dim Field As String
Dim Criteria As String
Dim RS As DAO.Recordset
Dim DB As DAO.Database
Set DB = Application.CurrentDb
Table = InputBox("Enter table")
Set RS = DB.OpenRecordset(Table, dbOpenDynaset)
Field = InputBox("Enter field")
Criteria = InputBox("Enter criteria")
RS.FindFirst (Field Like Criteria)
Find = Null
Do While RS.NoMatch <> True
Find = Find & Chr(13) & RS.Fields("Movex Code").Value & " : " & RS.Fields(Field).Value
RS.FindNext (Field Like Criteria)
Loop
RS.Close
Set RS = Nothing
Set DB = Nothing
End Function
ive got a problem with a search function
it only seems to work with constants not with variables
ive tried to use the field and criteria as a constant and table as var this works
but i need all of them as a var
im using Access 2002 / XP with VBA 6.3 and MS DAO 3.51 Object Library
Function Find()
Dim Table As String
Dim Field As String
Dim Criteria As String
Dim RS As DAO.Recordset
Dim DB As DAO.Database
Set DB = Application.CurrentDb
Table = InputBox("Enter table")
Set RS = DB.OpenRecordset(Table, dbOpenDynaset)
Field = InputBox("Enter field")
Criteria = InputBox("Enter criteria")
RS.FindFirst (Field Like Criteria)
Find = Null
Do While RS.NoMatch <> True
Find = Find & Chr(13) & RS.Fields("Movex Code").Value & " : " & RS.Fields(Field).Value
RS.FindNext (Field Like Criteria)
Loop
RS.Close
Set RS = Nothing
Set DB = Nothing
End Function