Results 1 to 8 of 8
  1. #1
    Douglasrac is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    92

    Question Single list with different fields

    Hi,

    I want to make a simple list, can be a query or a report, to just show some records. The problem is that I have fields in different tables, and they should be treated as equals.

    Like this:
    Fields:

    Table Clients
    Name
    Date of Bithday
    Phone Number



    Table Drivers
    Name
    Date of Birthday

    The report or query should show a simple list
    Name | Date of Birthday | Phone

    In one query I didn't manage to do it, since it will try to make Name of Drivers linked to Name of Client. Which is linked, but as I said, should be single list.

    So I did 2 queries. One for Clients and one for Drivers. Then I tried to list all records on a report, but the report wizard didn't accept data from more than one query.

    Anyway to solve this? Maybe transfer the queries list to a table? But in an automatic way, since the query is updated every month.

  2. #2
    kennejd is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    188
    Try a union query.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You can achieve one list with a UNION query:

    SELECT Name, Birthday, Phone
    FROM Clients
    UNION ALL
    SELECT Name, Birthday, Null AS Phone
    FROM Drivers
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Douglasrac is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    92
    You guys are perfect!
    So simple!

    Now I wonder if it's possible to change the name of the column in the query. Now it shows Expr1000, because the Name in Client's table is Drivers in Driver's table. So he Union All and put no name.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The query will use names from the first SELECT, so try

    SELECT Name AS TheirName, Birthday AS TheirBirthday, Phone AS TheirPhone

    or whatever you want as the alias names.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Douglasrac is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    92
    Thanks. Works perfectly.

    Now I just don't understand why the phone number is not showing with the mask, just the number. Even in the Table it shows with the mask, and now in the query its just the number. I have queries with the mask, why this one is different?

    P.S.: And another problem: I cant edit a UNION ALL query. There is a check box that I would like to check from the query. I'm wondering how can I solve this. I read that I would need to populate a temporary table and then edit there. But how? Copy paste, edit, then copy paste to the original table? Seems very risky.

    P.S.2: Seems very hard the solutions out there. Maybe if you know the purpose of the table you can find a better solution. The birthday table is done. Now I want to make a UNION query for other purpose. I have a check box for each record that says "Imported?". If the record have 0 in this field he will go to a query. This query will put together all records that I need to import to Google Contacts. So, when I finish to import the records, I mark them all. If I mark in the query is very easy. If I need to search in the form, one by one, and enter in several forms to reach this field and then mark, is a huge work load.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    A UNION query will always be read-only. If you're importing everything that has a 0, you can simply run an update query on the underlying table. This type of thing:

    UPDATE TableName
    SET FieldName = TRUE
    WHERE FieldName = False
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    Douglasrac is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    92
    Quote Originally Posted by pbaldy View Post
    A UNION query will always be read-only. If you're importing everything that has a 0, you can simply run an update query on the underlying table. This type of thing:

    UPDATE TableName
    SET FieldName = TRUE
    WHERE FieldName = False
    Love Access!

    But I need to update 2 tables at the same time.
    Here is what I did:

    UPDATE TableName, TableName2
    SET FieldName = TRUE And FieldName2 = True
    WHERE ((FieldName = False) AND (FieldName2 = False))

    But didn't work. And as I read, Access can't run multiple statements in one query. So I need to found another solution. Why the code above does not work?

    And what about the mask for the phone number? Union queries also don't show masks?
    Last edited by Douglasrac; 04-13-2011 at 06:49 AM.

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

Similar Threads

  1. Exporting single query and single report.
    By rfhall50 in forum Programming
    Replies: 2
    Last Post: 02-18-2011, 12:08 PM
  2. Replies: 7
    Last Post: 11-13-2010, 08:08 AM
  3. Exporting data from single fields
    By Kipster1203 in forum Import/Export Data
    Replies: 1
    Last Post: 08-06-2010, 10:02 AM
  4. Load tables name and fields name to list box
    By casseopia00 in forum Programming
    Replies: 1
    Last Post: 06-30-2009, 10:09 PM
  5. combining fields into a single list
    By rich in forum Queries
    Replies: 4
    Last Post: 02-23-2009, 06:41 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