Results 1 to 8 of 8
  1. #1
    Johnb is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Location
    Colorado
    Posts
    4

    Switching from record 1 to 2 form appears to change the data in the underlying table

    Hi all



    I suspect there's a simple explanation but I'm currently struggling and very confused.

    I have a table. It has 2 records in it. I've created a form. Added the various fields to the form.

    I've added a combobox on the form. Row source is the 2nd field in the underlying table. 1st field is a unique id.

    I'd like to select things in the dropdown, and have the rest of the information pertaining to that record populate the various text boxes (that are tied to the fields).

    I can't make it automatically update the fields, so I've written code that takes the contents of the text box, cycles through the underlying table, then displays the rest of the fields appropriately.

    For some reason, the contents of the field in the 2nd record copies to the contents of the field in the 1st record when I switch records.

    It's not because of the underlying code I've turned off the 'after update' code snippet. But when I try to have a combo box dropdown, that when I select something from the list then have it populate the rest of the text boxes, it always copies the data from the 2nd record to the first.

    This is my first post on this forum I'm sure there's a load of information that I need to put up here I'm not sure what it would be though?

    Many thanks for any help received,

    John B

  2. #2
    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,870
    John,

    Tell us about WHAT you are trying to do in simple English. You have described HOW you have done something that isn't working the way you want. We need to know about the something. Remember, we don't know you or the problem you are having. We recognize that you are new to the forum and want to help, but we need to know the requirement before offering responses for solution.

    Welcome to the forum.

  3. #3
    Johnb is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Location
    Colorado
    Posts
    4
    Okay.

    I have a table that contains organization information, the name of the organization plus other related information.

    I'd like to have a form that has a dropdown combo box, and the information in the combo box is the names of the organizations in the table.

    When a name of an organization is selected, I'd like the text boxes on that form to populate with the other related information that pertains to that organization.

    Seems like it should be simple, except when I change records, the name of the organization in the 2nd field copies to the name of the organization in the first field...

  4. #4
    Johnb is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Location
    Colorado
    Posts
    4
    Apologies make that 'the name of the organization in the 2nd record copies to the name of the organization in the first record'...

  5. #5
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by Johnb View Post
    Seems like it should be simple, except when I change records, the name of the organization in the 2nd field copies to the name of the organization in the first field...
    If you are trying to change records using the "name of the organization" combo box (which is probably bound), you would be changing the name of the organization of the current record, NOT changing to a different record.

    If you want to change to a different record using a combo box, the combo box would need to be unbound.
    The code in the after update event of the combo box would look something like
    Code:
    '****** Code Start *********
    
     'Move to the record selected in the control
     Me.RecordsetClone.Findfirst "[ID] = " & Me![ComboOrListboxName]
     Me.Bookmark = Me.RecordSetClone.Bookmark
    
     '******* Code End *********
    http://theaccessweb.com/forms/frm0005.htm


    Maybe you would post your code? Or your dB?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    You have couple options:

    1. apply filter

    Maybe this tutorial will help http://allenbrowne.com/ser-62.html

    2. move to record

    ssanfu has already provided an example
    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.

  7. #7
    Johnb is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Location
    Colorado
    Posts
    4
    Quote Originally Posted by ssanfu View Post
    If you are trying to change records using the "name of the organization" combo box (which is probably bound), you would be changing the name of the organization of the current record, NOT changing to a different record.

    If you want to change to a different record using a combo box, the combo box would need to be unbound.
    The code in the after update event of the combo box would look something like
    Code:
    '****** Code Start *********
    
     'Move to the record selected in the control
     Me.RecordsetClone.Findfirst "[ID] = " & Me![ComboOrListboxName]
     Me.Bookmark = Me.RecordSetClone.Bookmark
    
     '******* Code End *********
    http://theaccessweb.com/forms/frm0005.htm


    Maybe you would post your code? Or your dB?


    Thanks for that information ssanfu. I checked it out this morning and this looks like it! The record that was changing was bound so I removed that and all the testing so far indicates that this works. I've struggled with this for an age I can't tell you what a massive relief it is!!!! Thanks so much!!!!

  8. #8
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Happy to help.....

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

Similar Threads

  1. Replies: 6
    Last Post: 12-06-2015, 08:21 PM
  2. Replies: 12
    Last Post: 11-11-2014, 02:10 PM
  3. Replies: 3
    Last Post: 10-10-2013, 08:06 AM
  4. Replies: 0
    Last Post: 03-13-2012, 12:57 PM
  5. Form not updating underlying table
    By Kirsti in forum Forms
    Replies: 8
    Last Post: 02-10-2012, 12:23 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