Results 1 to 12 of 12
  1. #1
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234

    Linking columns in two different tables

    Shown below are tblEvent and tblRelEventEmployee. tblRelEventEmployee has a column named ShiftDate, and tblEvent has a column named EventDate. I need tblRelEventEmployee to pull the event date for each EventID from tblEvent and display it in ShiftDate. How can I do that?

    Click image for larger version. 

Name:	tblEvent.png 
Views:	18 
Size:	78.7 KB 
ID:	22127

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,970
    Did you try a query that joins the tables on the common EventID fields?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234
    I tried, but I didn't know how to do it. I created a query, and the tables are showing, but I don't know how to link the two fields based on EventID, nor do I know how to use the query once I do.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,970
    In query design - click on field in one table, hold and drag to field in other table. This will create the link line. Double click the line to open the relationship dialog. Set preferred JOIN type.

    Save the query object. It can be used as the source for a report if you want.

    I don't see any need for the event date to be stored in tblRelEventEmployees.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,745
    I recommend you do some searching on youtube for creating queries in MSAccess.

    Richard Rost(599CD) has a 10 or so set of tutorials here

    Also, it is easier for readers to assist you if you give a simple, plain English description of what you are trying to do --no Access, no jargon.
    Good luck with your project.

  6. #6
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234
    Quote Originally Posted by June7 View Post
    I don't see any need for the event date to be stored in tblRelEventEmployees.
    Short answer: I need tblRelEventEmployee to have the date so that I can easily reference the column in a textbox that is counting the number of shifts from April 15th. The control for the subform is tblRelEventEmployee.

  7. #7
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234
    This may be an easier way of doing this: Can I modify tblRelEventEmployee so that instead of having "ShiftDate" as a column, instead having "EventDate" as the column, with the info being supplied by tblEvent?

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,970
    Call it ShiftDate or EventDate, my comment is the same - see no need for the date in tblRelEventEmployees.

    Build a query that joins the tables on EventID fields and that will make the date available to each of the tblRelEventEmployees records.

    Is the textbox on form or report?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234
    The textbox is on a form.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,970
    So this textbox is on subform bound to tblRelEventEmployee? Is the main form bound to tblEvent?

    Why do you need to do this count on form? This kind of data calc is best done on report.

    However, the subform RecordSource can probably be a query that includes both tables, just don't use INNER JOIN and don't try to edit tblEvent fields from the subform.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234
    The reason it's on the form is that when I pull up an employee's information, I want there to be a box down at the bottom of the page that does a running count of all the events the employee has worked since 4/15/15. Since ShiftDate is blank, it's returning a 0

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,970
    Did you try the suggestion?

    Alternative is to build and save query object and use domain aggregate (DCount, DLookup, etc.) expression in textbox.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 4
    Last Post: 07-08-2014, 08:59 AM
  2. Linking columns to ID number in multiple tables
    By oakeoffice in forum Access
    Replies: 8
    Last Post: 11-08-2012, 07:10 PM
  3. Linking Tables
    By label027 in forum Import/Export Data
    Replies: 1
    Last Post: 11-07-2011, 05:16 PM
  4. Linking columns in access to a particular column.
    By israellawndale in forum Access
    Replies: 4
    Last Post: 08-16-2011, 02:55 PM
  5. Replies: 0
    Last Post: 03-04-2011, 10:28 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