Page 1 of 3 123 LastLast
Results 1 to 15 of 31
  1. #1
    DevState is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2018
    Posts
    35

    Reading in table

    Hello,
    I'm trying to find a solution to be able to have Access read every row in a column within a table, and evaluate another - seperate - table to see if there is a match.

    The purpose of this is to import a list of names, and search the table of names for a match and delete the name. I currently have the Excel spreadsheet import function up and going but need help on how to iterate through the names of the newly imported table against another table?

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    you do this with queries, you dont iterate.

    an inner join will find matches.
    a delete query will use the match query and delete the ones you dont want.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725

  4. #4
    DevState is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2018
    Posts
    35
    Quote Originally Posted by orange View Post
    DevState,

    I agree with ranman. Here is a link to w3schools --JOINs info.
    So if I use the inner join, can I have it go through the primary table and change the value of another record?

    So If the list imported had the name 'Smith', and it found 5 smiths in the primary table, could it change a value under the "Employed" column?

  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
    Post 4 was moderated, I'm posting to trigger email notifications.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    DevState,

    Can you tell us what these tables represent and why there may be duplicates and why some should/may be deleted?

    Smith or any Last Name is not very unique generally. When you want to compare records, you need some field(s) value(s) to ensure uniqueness.

  7. #7
    DevState is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2018
    Posts
    35
    The spreadsheet being imported as a table is of employee names. I want to check that against a database of employee names that are tied to certain events. Each employee listed in my database can have several different events they're running and if their name is on the spreadsheet that was imported, it means they no longer are working for me. Thus, I would want to trove through my employee table and make sure to change their status to "No longer employeed".

    Hope that helps?

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725

  9. #9
    DevState is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2018
    Posts
    35
    I would still need to figure a way out for each employee, to switch another field by their name to "No longer employed". Also, I can't seem to get a split function to break a name up that comes in like "Smith,John, H".

  10. #10
    DevState is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2018
    Posts
    35
    I'm not sure an Inner join is what I am looking for?

    I simply need Access to look at the new "Terminations" table and run each name against the "Individual" table. If it finds a match, it makes sure the "Status" column is set to "Terminated" and moves to the next record. Can I do this with an Inner Join?

  11. #11
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    Show readers some data.
    Show us your Employee table design and some sample records.
    Also include some data from your spreadsheet.

  12. #12
    DevState is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2018
    Posts
    35
    Individual Table (This is already in the DB as 'Individual')
    Click image for larger version. 

Name:	Capture.PNG 
Views:	21 
Size:	8.6 KB 
ID:	34766

    This is the table that was imported from the spreadsheet (Named 'Terminations'):
    Click image for larger version. 

Name:	Capture1.PNG 
Views:	21 
Size:	4.6 KB 
ID:	34767

    The terminations Db only has a few same first and last name since that is the only criteria I will be needing to search records in the Individual table with. I need to be able to have the system, on click, automatically evaluate all names in the terminations table against the Individuals table and label those that it found as "Terminated" under the Status column.


    EDIT: I may have figured it out simply using a For loop to iterate through Terminations and each one searched against the Individual table with action.

  13. #13
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    What is the difference between Individual_ID and Individual_Employee_ID?

    Since you have this data in a database, can you post a copy of the database (with only a few records) in zip format.

    First and Last are poor choices of field names.

  14. #14
    Join Date
    Apr 2017
    Posts
    1,679
    Probably this will do for task you asked for.
    Code:
    DELETE FROM Individuals
    WHERE Individual_Employee_id IN (SELECT EmplID FROM Terminations)
    Another thing is, that you may consider having a field e.g. TerminationDate in table Individuals, and you use an update query instead, which fills TerminationDate with value from field [Effective Date] in table Terminations. So you can have info about individuals from past whenever you need it.

  15. #15
    DevState is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2018
    Posts
    35
    I can't post this kind of information. I seem to have figured out how I want to approach it but onto the next issue... the following is throwing the infamous error " syntax error (missing operator) in query expression 'Last Name = 'Hansen"

    I've tried many different things, any ideas?

    Code:
    If DCount("Case_Number", "Individual", "Last Name =" & "'" & var & "'") > Null Then
    EDIT: Yes, the naming conventions are off because I'm simply testing these features and will rewrite proper ones when I complete it. Thank you!

Page 1 of 3 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. problem reading table from VB code
    By nello87to in forum Modules
    Replies: 3
    Last Post: 08-16-2016, 01:59 PM
  2. Reading XML
    By ricksil in forum Programming
    Replies: 1
    Last Post: 05-17-2016, 08:47 AM
  3. Reading VBA code
    By ksammie01 in forum Access
    Replies: 11
    Last Post: 01-11-2013, 03:40 PM
  4. Control Source on Form Reading Value in Table
    By hammer187 in forum Forms
    Replies: 1
    Last Post: 10-23-2012, 02:43 PM
  5. Reading row length
    By dnlhmpt in forum Import/Export Data
    Replies: 2
    Last Post: 01-31-2012, 07:47 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