Hi
Im creating a function that takes a value, searches for it in a database and returns either the value, if found or an empty string if not found.
Im trying to whittle down my code by creating a single function to search any database / recordset.
The inputs are: database name & location, table name, field name, value to search for and criteria e.g
"c:\database\mydb.mdb", "LOGIN", "USERNAME", "TestName", "WHERE USERNAME = '" & txtValue "'" (txtValue = TestName).
This would search the database c:\database\mydb.mdb for a table called LOGIN. Once the tabledef has been found, a recordset would be opened using the criteria.
At the moment, if it finds the value, it returns the value to search for field e.g fQueryDB=txtValue. What Im trying to acheive is instead of returning the value to search for field, simply pass it the criteria and get in return the resulting value from the field, if any.
Example: I would pass it criteria "WHERE USERNAME = '" & txtSearchValue & "'" (txtSearchValue = "TestName" and set the field as FULLNAME, then get in return the value of the value of FULLNAME in the calling procedure, e.g "The Test User Name".
Any ideas ?
Missy Ed
Looking to exchange ideas and tips on VB and MS Access. Drop me a line: msedbbw@hotmail.com
Im creating a function that takes a value, searches for it in a database and returns either the value, if found or an empty string if not found.
Im trying to whittle down my code by creating a single function to search any database / recordset.
The inputs are: database name & location, table name, field name, value to search for and criteria e.g
"c:\database\mydb.mdb", "LOGIN", "USERNAME", "TestName", "WHERE USERNAME = '" & txtValue "'" (txtValue = TestName).
This would search the database c:\database\mydb.mdb for a table called LOGIN. Once the tabledef has been found, a recordset would be opened using the criteria.
At the moment, if it finds the value, it returns the value to search for field e.g fQueryDB=txtValue. What Im trying to acheive is instead of returning the value to search for field, simply pass it the criteria and get in return the resulting value from the field, if any.
Example: I would pass it criteria "WHERE USERNAME = '" & txtSearchValue & "'" (txtSearchValue = "TestName" and set the field as FULLNAME, then get in return the value of the value of FULLNAME in the calling procedure, e.g "The Test User Name".
Any ideas ?
Missy Ed
Looking to exchange ideas and tips on VB and MS Access. Drop me a line: msedbbw@hotmail.com