Results 1 to 11 of 11
  1. #1
    Crewmate is offline Novice
    Windows 10 Office 365
    Join Date
    May 2024
    Posts
    3

    Question Changes in form lead to wrong Changes in table


    Hi there,

    first of all, I apologise if any of my terminology is wrong, because English is not my first language and thus my Access is not in English as well.

    I have a school project and I am pretty much panicking because I am way in over my head.

    You can find my file here: https://www.dropbox.com/scl/fi/pwjdo...uxa2orini&dl=0
    Sorry for the dropbox link, the file was too big for upload directly in the forum. There are quite a few tables, queries and forms but I will describe exactly where the problem is. None of the data in this real, so don't worry about privacy.

    First of all: In the table with the customer data there are a few data points which are saved as a number although they represent other terms. In this case these are the three fields that are comboboxes: "Anrede" (salutation), "Bundesland" (federal state) and "Bonität" (credit score). But as an example we can just talk about the salutation. In the table "Kunden" (customers) the salutation is represented as a number from 1 to 3. These are the IDs from the table "Anrede" (salutation) where the salutaion is stores as a word if that makes sense. So 1 is "Frau" (Mrs.), 2 is "Herr" (Mr.). This is the way we were supposed to do it. I have no Idea if it is done this way in the real world.

    In my database I have a problem when it comes to the way this information is displayed in a form and the affects changes have. If you check the file, your basis should be the form "formKundenübersicht" which just displays all of the customers. If you click on any of the hyperlinked numbers in the first column you will get into a form where you are able to edit all the customer information. I wanted this to be a combobox so only the given options can be chosen. The problem is, if I change the salutation here from one to the other, it does not change the salutation of this one customer. It changes it in the table "Anrede" (salutations). So if it says "Herr" in the form and I change it to "Frau" it changes the entry in the table "Anrede" itself.

    I tried for hours to fix this but I don't know where to go from here. Can you help me?

    If anything is unclear or if you have any questions, please don't hesitate to ask.

    Thanks a lot in advance.

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,448
    Rather confusing schema, with table names same as data names within, foreign keys same name as data field in lookup table, use of special characters in data names as well as being in German. Any how, addressing your described problem, the lookup comboboxes are not being set up properly. Here's how.
    Code will update the foreign key named Anrede in table Kunden instead of field Anrede in table Anrede. See how confusing the duplicate data names and object names can be? Anrede is data type short text in table Anrede, but data type long integer in table Kunden. Same name but certainly not same data content.
    Also much info about this via google and youtube.

    Click image for larger version. 

Name:	propsheetData .png 
Views:	48 
Size:	45.3 KB 
ID:	51814

    Click image for larger version. 

Name:	propsheetFormat .png 
Views:	48 
Size:	24.6 KB 
ID:	51815
    Last edited by davegri; 05-21-2024 at 08:39 AM. Reason: clarification I hope

  3. #3
    Crewmate is offline Novice
    Windows 10 Office 365
    Join Date
    May 2024
    Posts
    3
    Hi davegri,
    thank you so much for taking a look at my mess. In the beginning I didn't know about naming schemes and regret not having learned to usem them properly before starting this project. I will try renaming things, but I am afraid to break something.

    Anyway, thank you for your adivce. Unfortunately your solution does not seem to solve the problem. When I am for example editing the first customer and change the salutation from "Herr" to "Frau" and go back to the customer list "fromKundenübersicht" all of the salutations that used to be "Herr" are now "Frau" for all customers. When changing the option in the Combo Box it does not change the salutation in the respective customer, but it edits the the table "Anrede" (which I already changed to tabAnrede thanks to your advice).

    Do you know what I mean? Would you be able to take a look at that?

  4. #4
    Crewmate is offline Novice
    Windows 10 Office 365
    Join Date
    May 2024
    Posts
    3
    I did what I should have done in the first place and created a small mock-file with only the necessary parts. Sorry that my sleep-deprived brain didn't think of this before:

    https://www.dropbox.com/scl/fi/rgv6p...ouy9fmhcl&dl=0

    I hope this helps a little in making it easier to understand the problem.

    In this test file I deliberately did not use a combo box because I found out that this happens with or without it. So the Combobox wasn't the problem.

    If you go into the main form "fromKundenübersicht", click on any of the hyperlinked IDs on the left and then change the salutation ("Anrede", second field from the top) the change will not affect the data in "tabKunden" but in "tabAnrede".

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,090
    If you now have a small file you can upload it here?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,584
    Hi Wgm

    Here is the file that was in Dropbox.
    Attached Files Attached Files
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  7. #7
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,671
    You may want to re-think formatting your PK in the table.

    Click image for larger version. 

Name:	frmttbl.jpg 
Views:	31 
Size:	13.6 KB 
ID:	51817
    If need be, do the formatting in the form for display.
    Your PK should be meaningless other than to identify a unique record.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,478
    If you go into the main form "fromKundenübersicht", click on any of the hyperlinked IDs on the left and then change the salutation ("Anrede", second field from the top) the change will not affect the data in "tabKunden" but in "tabAnrede".
    Think you mean 'AnredeText, second field from the bottom.
    It doesn't for me. tabKunden has the new value for Anrede_FK

    What I find confusing is whichever record I select, it always opens to the same one (record 9). Are you sure you are looking in the right place?

    Also, you do have to save the record by moving to another record or closing the form before the table will be updated.

  9. #9
    davegri's Avatar
    davegri is online now Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,448
    Design problem. If you try and add a record, the form will force you to input a new salutation which will ADD a record to tabAnrede:

    Click image for larger version. 

Name:	designprob.png 
Views:	26 
Size:	25.8 KB 
ID:	51819

    To fix the Anrede assignment, add this code:

    Click image for larger version. 

Name:	combo.png 
Views:	26 
Size:	31.7 KB 
ID:	51818

    Note that the Test database does not load the selected ID into the called form, it always loads the first KD-ID.

  10. #10
    madpiet is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    189
    (Having a separate primary key for a tiny table seems like a really odd thing to do... If it's only a handful of values, why not just store the real value?) Part of me thinks this is going normalization crazy. I mean, I get it if you have a data warehouse fact table with a billion rows, but with a tiny table? what are you really saving?

  11. #11
    davegri's Avatar
    davegri is online now Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,448
    Quote Originally Posted by madpiet View Post
    (Having a separate primary key for a tiny table seems like a really odd thing to do... If it's only a handful of values, why not just store the real value?) Part of me thinks this is going normalization crazy. I mean, I get it if you have a data warehouse fact table with a billion rows, but with a tiny table? what are you really saving?
    The strongest argument for having small lookup tables is this:
    With an ongoing database, what if you want to change an existing salutation from, say Mr. to Mister? If you just start using Mister, what about the dozens or hundreds or thousands of existing Mr. ?
    If you have it in a lookup table, you change it once in the table and it's automatically propagated to all existing instances throughout the database via the key relationships.
    Last edited by davegri; 05-22-2024 at 05:47 PM. Reason: edit

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

Similar Threads

  1. Replies: 3
    Last Post: 01-25-2024, 02:46 PM
  2. Replies: 5
    Last Post: 11-20-2020, 05:20 PM
  3. Public function for lag and lead?
    By sergi117 in forum Programming
    Replies: 3
    Last Post: 10-10-2018, 07:49 AM
  4. Replies: 4
    Last Post: 08-21-2014, 05:36 AM
  5. Replies: 1
    Last Post: 09-30-2011, 06:54 PM

Tags for this Thread

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