Results 1 to 9 of 9
  1. #1
    mikke3141 is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    3

    New to Access


    Hi,
    I'm trying to update a Access database and now the update is updating too much. I need to get the country information from a linked country table so that the correct value (countryID) is maintained in the employee table. Now the first example changes the country table what is should not. How do I get so that the access update expression picks the correct key from the country table based on the country name? The first picture updates the country table, but I just want the matching number to employee tableClick image for larger version. 

Name:	snap1.png 
Views:	24 
Size:	8.2 KB 
ID:	40034. The second picture shows what I would like to code to do, but it does not work Click image for larger version. 

Name:	snap2.png 
Views:	24 
Size:	8.8 KB 
ID:	40035

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,970
    You aren't saving country name in EmployeeTbl. This UPDATE makes no sense.

    You select CountryID from combobox during data entry to EmployeeTbl.
    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
    mikke3141 is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    3
    Yes I know that the first box makes no sense, but it was just to show the issue in hand. I know that I can select the CountyID from the combobox to maintain the data to to EmployeeTbl, but the combobox is not an option as I need to copy the generated SQL statement to an excel ADO SQL-string. I use the access query just to generate the code itself. The second picture shows what I am trying to do.

  4. #4
    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,745
    Welcome Mikke3141,

    A few things before your specific issue.
    Name is a reserved word in Access. Here is a link to more info on reserved words.

    Choose a naming convention for field and object names that does not allow embedded spaces. You will avoid many syntax issues when using this approach.

    When you post, it helps readers if you tell us about your application in overview using simple. plain English.
    For example, we are a small importing business. We import products from suppliers in Italy, Germany and Greece.....

    There are database principles that, if followed, will simplify usage of the database and streamline some processes. Key to these is normalization which is not dependent upon MS Access, but is a technique for the efficient design of relational databases. Here is a link to Normalization info, but there are several and researching a few will help you with design.

    I suggest you build a model of your tables and relationships - can be done with pencil and paper before getting too committed to a physical database that is difficult to modify.

    The Database Planning and Design link in my signature has many articles in different formats that should be useful to you.

    You may also review this material on Join Types by member isladogs.

    Good luck with your project.

    Crossposted @ https://access-programmers.co.uk/for...d.php?t=307533

    Mikke3141 -- see this re Cross posting
    When you submit the same or similar post to multiple forums, always supply the link(s) to the other posts.

  5. #5
    Join Date
    Apr 2017
    Posts
    1,688
    You must have your form based ONLY on EmployeeTbl;
    On form you'll have a combo box with control source linked to EmployeeTbl.CountryID;
    Combo box row source must be a query from CountryTbl (like 'SELECT CountryID, Country FROM CountryTbl ORDER BY 2'). Linked column must be 1, column count must be 2, and column widths must be like '0,2.5'.

  6. #6
    mikke3141 is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    3
    Thank you, but as I stated earlier Combo box is not an option as I update the database through Excel using ADO and and a SQL-string. Access Forms are not part of the solution.

  7. #7
    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,745
    Perhaps you could post the SQL-string along with a description of what you want to accomplish.
    Is this a 1 record issue, or multiple records, multiple conditions...?

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,970
    What you want is not possible with datasets provided. Country name is not in EmployeesTbl, therefore it is not possible to link to another table on country name so as to retrieve country ID. Again, your request makes no sense.
    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
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529

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

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