Locate tables where value is found

D

Dale_Fye via AccessMonster.com

Create a loop to loop through all of the tables in your database, then loop
through each of the fields to search for the value you are looking for. Is
that all you want to know, or do you want to know what record and field it is
in? How do you want to display the information?

Inside the loops, you would need to:
1. Test to see whether the field.type is similar to the varType of the value
you are looking for. If the Field.type is a Date field, there is no sence of
checking that against at text value.
2. Then, you wil need to format a select statement to count the number of
records in the table where the field contains or is equal to the value you
provided. If you are searching for text, then you would need to format the
SQL statement to include wildcards where appropriate (exact match, begins
with, ends with, contains).
3. Open a recordset based on the SQL to determine the matching records. If
all you want to know is how many values were found in the table, you could
either use a msgbox, debug.print, or could create an array or table to store
your results.
4. If you want to identify the actual records that contain the value, that
would be another level of difficulty.
5. Close the recordset

HTH
Dale
 
T

Tom van Stiphout

On Fri, 22 May 2009 03:52:14 -0700, QB <[email protected]>
wrote:

In a good db design this is never a question, because it can be in
only one table.

If you truly don't know, then you can write some DAO code to loop over
all tabledefs, and within a tabledef over each field, and query that
field for your value.

-Tom.
Microsoft Access MVP
 
Top