Results 1 to 9 of 9
  1. #1
    Tomfernandez1 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    74

    Search Across Multiple Tables

    Not sure if this is the right place to post this, so forgive me if it is not.

    I have a 2003 Access database that has multiple Tables. Each Table has similar fields titled "First Name"; "Last Name" in addition to other uncommon fields.

    Is there a query or code that would search, across all Tables, for "Bill"; "Smith" respectively in those common fields?



    I have a Form set up where I can set up the query/code if necessary.

    Your attention to this post is much appreciated!

    Tommy

  2. #2
    SteveF is offline Generally AccessAble
    Windows XP Access 2010 32bit
    Join Date
    Nov 2010
    Location
    Fourth Corner
    Posts
    123
    Quote Originally Posted by Tomfernandez1 View Post
    Not sure if this is the right place to post this, so forgive me if it is not.

    I have a 2003 Access database that has multiple Tables. Each Table has similar fields titled "First Name"; "Last Name" in addition to other uncommon fields.

    Is there a query or code that would search, across all Tables, for "Bill"; "Smith" respectively in those common fields?

    I have a Form set up where I can set up the query/code if necessary.

    Your attention to this post is much appreciated!

    Tommy
    A few questions, if you don't mind -- to start, is the "Bill Smith" in table #1 the same person as "Bill Smith" in table #2, table #3, and so on??

    If so, then I'm going to strongly recommend a thorough table redesign, as there's a lot of redundancy here and a lot of chances for data errors that will really screw things up down the road!

    Steve

  3. #3
    Tomfernandez1 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    74
    Hi Steve- "Bill Smith" is the same person in multiple Tables. I agree that my database has flawed Table designs, and I hope to rectify this in the coming months. I have been reading up on nomalization; I hope to get my database normalized soon!
    -Tommy

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Tom,

    no one here has answered your question yet, soooo....the answer is YES. But what is the point? What do you want to do with all of it? Delete all the dups?

  5. #5
    Tomfernandez1 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    74
    Adam - the Tables represent different months of the year (again, bad design) so I want to know the number of months "Bill" "Smith" is found in a year, and review data from some of the different fields within the Tables that show "Bill Smith".
    -Tommy

  6. #6
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by Tomfernandez1 View Post
    Adam - the Tables represent different months of the year (again, bad design) so I want to know the number of months "Bill" "Smith" is found in a year, and review data from some of the different fields within the Tables that show "Bill Smith".
    -Tommy
    I see. there isn't a query that does this. that would be 12 tables, rigth? you could write nested IIF() with dlookups in them for each table, but I'm guessing 1,000 records in each of 12 tables, that would take minutes to run. So that's out.

    Why not a VBA call using dcount() to count the distinct values in one of the tables that you query? that might be an option, although speed might be an issue. depends on size.

    regarding your 'bad design', forget it. I just get so sick of people preaching about normalization. It's like a PHD program...it shoulda shoulda shoulda been done this way. Well guess what? I've never had a customer say this to me:
    I'm only gonna use your service if your database that you use for my info is normalized
    but I HAVE had someone say this:
    if you cant get it done in a hour, forget it
    hmmm....yeah, forget the customer. normalization is more important to me.

  7. #7
    Tomfernandez1 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    74
    Adam - what is the preferred method for using dcount() in a query....would it be in SQL or query design view? Also, is there a VBA method for searching all tables for specific information (Bill Smith)? I was hoping for a code that would work like a 'ctrl+f' function, covering all tables, but I am discovering that such may not exist.. Thanks for your continued support!
    -Tommy

  8. #8
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    i don't think ctrl+f works in all tables. just columns and/or one table.

    as far as FINDING info in tables? that's really kind of pointless in vba unless you want to do something with it. you say you want 'review' some related info of all the Bill Smith's, so if you want to do that, I really don't think there's a fast way to do it.

    you could use recordsets and iterate, but you'd have to do it in every table. you could also write one query per table, which is interface, so you don't have to mess with code.

    and of course, if the tables could be joined somehow, you could use that join in a qry, but then again, from what it sounds like, the design problem will prevent you from doing it this way.

    it doesn't take me much time to write vba code, so I would iterate the tables using an array of table names and recordsets, but it's up to you here though.

  9. #9
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682
    If you have multiple tables with First name and Last name fields and you want to match names between tables, have you considered creating a text field in each table to save a 'concatenated' type of value. For example, when updating the first or last name on the form (probably along with another field such as city or zip), you could combine and save characters from each of these fields into a single field to make matching across tables a little easier (ie. JSmithParkSt50322).

    It could be a quick table/code modification without having to redo any table relationships and creating queries to find matching names would be a bit easier versus joining on mulitple fields (and writing vba to open recordsets to find matching records on a single field would be a little bit easier.)

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Search for multiple records
    By Blake in forum Queries
    Replies: 1
    Last Post: 08-23-2013, 03:17 AM
  2. Search with multiple criteria
    By injanib in forum Forms
    Replies: 1
    Last Post: 01-16-2011, 11:51 PM
  3. Search across tables
    By bryan in forum Access
    Replies: 3
    Last Post: 12-30-2010, 11:00 AM
  4. Replies: 4
    Last Post: 09-22-2010, 01:47 AM
  5. How can I search multiple tables?
    By botts121 in forum Access
    Replies: 4
    Last Post: 02-02-2010, 06:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums