Access 2010 - Make Table Query Losing LookUp data
Results 1 to 6 of 6

Thread: Access 2010 - Make Table Query Losing LookUp data

  1. #1
    New Member
    Join Date
    Jul 2006
    Posts
    41
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Access 2010 - Make Table Query Losing LookUp data

    I have an Access "Membership-type" database with two tables as follows:
    - [Countries] with the "CountryID" field set to autonumber and Primary Key and "ContactCountry" set to text
    - [Members] with the usual data for a membership database including a "Country" field set to Number (using the Lookup wizard) and the following automatically set for the Lookup Tab Combo box, table/query, SELECT [Countries].[CountryID], [Countries].[ContactCountry] FROM [Countries] ORDER BY [ContactCountry]; . Another Field in this table is a Date Field "Renewal Date" which tells me the data when the member has renewed to.
    I've created a Make Table query that uses the [Members] table (in which the Country field is a Combo Box display the NAME (not Record ID) of the Country) which returns all the fields of the [Members] table but only those records where the "Renewal Date" field contains a date greater than "a month ago" ie giving the member one months' grace and pastes them into a new table [Currently Active Members]

    The SQL for the query is:

    SELECT [Members].*, IIf([Renewal date]<=DateAdd("m",-1,Date()),False,True) AS Active INTO [Currently Active Members]
    FROM [Members]
    WHERE (((IIf([Renewal date]<=DateAdd("m",-1,Date()),False,True))=True));

    The query runs OK and returns the correct data. However in the newly created table [Currently Active Members], the "Country" field now contains a number (which is of course the Record ID from the [Country] table and NOT the Text of the Country or as I would prefer it, the actual Combo Box with the name of the Country showing. Am I asking too much of Access to show the data as it was originally supplied to the query?
    Any thoughts?

    Dave Kennedy
    Scotlandwell

  2. #2
    MrExcel MVP
    Moderator
    xenou's Avatar
    Join Date
    Mar 2007
    Location
    Clev. OH, USA
    Posts
    16,422
    Post Thanks / Like
    Mentioned
    11 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Access 2010 - Make Table Query Losing LookUp data

    Make table queries will not have lookups in them. If you want that you could create the table beforehand and populate it with an insert query rather than using a make table query (naturally you will first need to delete records from the table so you will have a "fresh" set of records each time you want to populate the table - end result will then be the same as what you have with your make table query).

    Using: Office 2010/Win7 (work) Office 2010/Win7 (home)

    You are rich in proportion to the number of things you can let alone.
    -- Henry David Thoreau

  3. #3
    New Member
    Join Date
    Jul 2006
    Posts
    41
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Access 2010 - Make Table Query Losing LookUp data

    Thanks xenou. I guess I just don't understand the inner workings of how Access makes a table from a MakeTable query. If I create a new table (as in Create|Table) then go to my membership table and copy a Record, when I paste it into the new table, the Look up is carried with it. Wishful thinking, but I would have thought that on running the MakeTable query, every time a record is checked and meets the Criteria, the record is selected then "pasted" into the new table - but obviously not.

    The good news is, however, (having had a play with it), in Design view of the table made as a result of the query, change the Data Type of the Country field from Number to LookUp, then on running the wizard, select the Countries Table and everything is then how it should be, complete with Combo Box etc. Pity Access isn't that smart!!

    Thanks again.
    Dave
    Last edited by daveatthewell; Jul 2nd, 2019 at 05:28 PM.

  4. #4
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    49,998
    Post Thanks / Like
    Mentioned
    52 Post(s)
    Tagged
    11 Thread(s)

    Default Re: Access 2010 - Make Table Query Losing LookUp data

    It looks like the table you are making has all of the fields of the Members tables, plus one more (the Active field).
    So what I would probably do is copy the structure of your Members table (right-click on the Table, select Copy, right-click and select Paste and choose the "Structure Only" option).
    Then manually add the Active field to this new blank table copy.
    Then you can do an Append Query from the original table into this new table, much like xenou described.
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

  5. #5
    Board Regular
    Join Date
    May 2013
    Posts
    618
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Access 2010 - Make Table Query Losing LookUp data

    Lookups in Access tables confuse a lot of people. I believe most developers do not use them, as they just disguise the fact that all that is really held is a key.?
    When you create a query and then ask for County="Wales", it will not work.

    One of my first DBs used lookups, but now I do not use them. Instead I link them in the conventional way. That way I see the 'true' data, if I ever have to go direct to a table.
    Office 2007
    Access novice. Sometimes trying to give something back

  6. #6
    New Member
    Join Date
    Jul 2006
    Posts
    41
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Access 2010 - Make Table Query Losing LookUp data

    Thank you all for your advice/help. It is much appreciated.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •