Results 1 to 4 of 4
  1. #1
    Top Tuna is offline Novice
    Windows 8 Access 2016
    Join Date
    Apr 2020
    Posts
    12

    Combobox data being overwritten when database is closed

    I have written a small database which is designed to record incoming and outgoing medication for three people. When I open the database I set the name of the person for whom the medication belongs using a combo box containing the three names. All the forms, queries and reports display and calculate the date for that particular person. It all works well until I quit the program using a macro to quit, which saves the database before it shuts. Say the three names in the table are John (record 1), Mary (record 2) and James (record 3). When I reopen the database the last user to have been accessed has their name replace the first record holder. Say James was the last person accessed in the previous session, his name has overwritten John, who was the name in the first record. Apart from ensuring the first record (John) is the last name to be accessed before I quit, how can I prevent the first record from being overwritten.

    I would be grateful if someone has a solution for me.
    Cheers Top Tuna

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Two things - when you use combos to filter results, you usually don't bind them to a field because choosing a value saves that value in the field. So the fix is to remove any control source property for the combo. You then need a macro or code to filter your form based on that choice (typically the control AfterUpdate event).

    The other thing is, there is no such thing as closing Access and expecting you can control what has been saved or not. Access is not like Word or Excel. You change data in any bound control or query field and the change is done - immediately at the point that you do anything to save the record. This includes, but is not limited to, moving off a record, moving from a main form to a sub form, or running any code or macro that causes it. Don't think that because you close the db without clicking the save button that you can undo any changes. You might want to research some term(s) like "ms access use combo box to filter records" or some such thing.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Top Tuna is offline Novice
    Windows 8 Access 2016
    Join Date
    Apr 2020
    Posts
    12
    Thanks Micron. That works with that change you recommended. Cheers

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Happy to help. Good luck with your db!
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 7
    Last Post: 04-01-2019, 01:02 PM
  2. help create a closed database
    By izhar in forum Access
    Replies: 4
    Last Post: 07-12-2017, 04:01 PM
  3. Field Being Overwritten
    By leanbiz in forum Forms
    Replies: 4
    Last Post: 08-11-2014, 10:05 PM
  4. Replies: 1
    Last Post: 09-27-2013, 04:07 PM
  5. Replies: 4
    Last Post: 08-17-2011, 05:30 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