Results 1 to 9 of 9
  1. #1
    bespra is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2010
    Posts
    20

    Creating relationship where none exists

    I am attempting to update my tblMasterDap which does not have any data with another table called tblPublications which has data. I don't want to retype the data into the master table. I created a primary key Master ID in the master table and a foreign key in the tblpub table, but when I run the append query it gives me no records.

    I have attached the fields I have for each table.

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Can you post your DB here?

  3. #3
    bespra is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2010
    Posts
    20

    Creating relationship

    Here is my db

  4. #4
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Both the tables are empty.

  5. #5
    bespra is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2010
    Posts
    20

    Creating Relationships

    The Master table is supposed to be empty for now. What I am doing is importing older data from excel into the publication table, then it needs to go to the Master table. After that is done the form will be used for inputing new info into the pubs table and updating the master table.

    Hope you can help me.

  6. #6
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    . . . sorry
    Last edited by Robeen; 09-21-2011 at 09:14 AM. Reason: incomplete post - hit Submit in error.

  7. #7
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I don't have the time to construct the entire query for you because your fields are not identically named in the two queries and I'm a little busy right now but here is a start for you.

    Use this as a template that you can build on:

    Create a Query and select all the rows from tblMasterDap that will receive data from tblPublications.

    Then go into SQL View [View -> SQL View] and add an INSERT INTO row that contains all the fields in tblPublications that have data that needs to go into tblMasterDap.

    The fields in the INSERT INTO row need to be in the same order as the fields in the SELECT row. Access will match the field names by the order in which they appear in the two rows in your SQL and append the data accordingly.

    Code:
     
    INSERT INTO tblMasterDap ( [Pub ID], [Title/Subject], [Media Tier] )
    SELECT tblPublications.[Pub ID], tblPublications.[Title/Subject], tblPublications.[Media Tier]
    FROM tblPublications;
    Save and run the query. See if the correct data from tblPublications was put into the correct fields in the master table.

    I ran the Append query as I showed in the SQL above and it inserted the two rows of data for those three fields.

    I hope this helps. Let me know if there are still problems.
    Last edited by Robeen; 09-21-2011 at 11:06 AM. Reason: [/CODE] tag before end of Code!

  8. #8
    bespra is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2010
    Posts
    20
    Works great, thanks.

  9. #9
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Happy to Help!

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

Similar Threads

  1. If table exists then
    By SorenIX in forum Programming
    Replies: 2
    Last Post: 06-26-2011, 08:42 AM
  2. Creating a driving relationship on a form
    By ld8732 in forum Database Design
    Replies: 1
    Last Post: 12-31-2010, 06:20 AM
  3. Not Exists Between Query
    By Pells in forum Queries
    Replies: 5
    Last Post: 11-08-2010, 06:13 AM
  4. Add columns if not exists
    By ysrini in forum Access
    Replies: 1
    Last Post: 02-16-2010, 06:39 PM
  5. How to use if not exists in access?
    By halifaxdalRaymondXie in forum Queries
    Replies: 1
    Last Post: 01-14-2010, 03:18 PM

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