Results 1 to 6 of 6
  1. #1
    prinsr is offline Novice
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    3

    Exclamation Ms Access Client Database Question

    Hi



    I must create an access database that auto generates a client number(which is used as my primary key) for each company. This part i got covered and it works well. the problem is that i must also add employees from the companies under their respective companies. Is there anyway of doing this?

  2. #2
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    So you want to have an additional field "Companies" in the same table as your employees and put the company name next to each employee.

  3. #3
    prinsr is offline Novice
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    3
    @nick404 And use that as the FK? How will i then run a query to list all the employees of that company?

  4. #4
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    You could have the company be a foreign key yes, and then have another table with the companies as the primary key (and could just use that to keep company addresses if you need or products you buy from them, w/e).

    The query will something like:

    SELECT tblEmployees.Employee, tblEmployees.Company_FK
    FROM tblEmployees INNER JOIN tblCompanies ON tblEmployees.Company_FK = tblCompanies.Company_PK
    WHERE tblEmployees.Company_FK = [Enter company name to search];


    This will prompt you to "enter company name to search" when you run the query and then whatever company name you type in it should return all the employee of that company. The table names and field names are hypothetical so tailor it to what you actually have. The foreign key and primary key I name as _FK and _PK so that I can keep track of what is all related easier.
    Last edited by nick404; 07-15-2015 at 08:00 AM. Reason: fixed sql (error)

  5. #5
    prinsr is offline Novice
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    3
    Awesome stuff, I didn't think of that. Thanks for the SQL code tho, my SQL coding is near to non-existent.

  6. #6
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    Yep no problem! If something doesn't work or have further questions let us know

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

Similar Threads

  1. Replies: 3
    Last Post: 04-23-2024, 06:59 AM
  2. Replies: 3
    Last Post: 06-02-2014, 02:58 PM
  3. A question about client/server
    By kosti in forum Access
    Replies: 1
    Last Post: 12-06-2011, 08:22 AM
  4. Replies: 3
    Last Post: 07-20-2011, 01:04 AM
  5. Client Server Database
    By vaikz in forum Database Design
    Replies: 4
    Last Post: 08-02-2010, 04:33 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