Results 1 to 10 of 10
  1. #1
    Tonyb123 is offline Novice
    Windows 10 Office 365
    Join Date
    Dec 2023
    Posts
    8

    How to update a form with combo box data but not add record to combo source table

    Hope someone can help,

    I have a split form with a combo box on the main form "frmCompany" that populates the forms Company Name and Company Branch and Company ID text box's. The Main and sub form has a Master/Child CompanyID relationship.
    The data on the Sub Form saves to "tblProject"
    This works well.
    The Problem is... Every time I use "save and new" or "save and close" button on the main form, the "frmCompany's" Table "tblCompany" updates with a duplicate Company Name, Branch and ID.
    Tried various event snippets, snapshots settings, and cross tab query without success.


    To sum up I want to save the new record to the Project table and leave the Company table data unchanged.

    Many thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Suggest you provide db for analysis. Follow instructions at bottom of my post.
    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
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Save and New I can uderstand.
    Form should be bound, so no Save needed.

    As mentioned upload your DB or at least the code behine the buttons. Please post the code within code tags, using the # icon.

    This is one of these 'How long should my bit of string be?' when we have no idea what the string is for.
    Last edited by Welshgasman; 12-12-2023 at 01:43 AM.
    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

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    From what you describe I think the issue is related to your combo; it looks like you use the combo to search for the company in the main form then add a record in the projects subform. The combo needs to be unbound and have code behind the AfterUpdate event to find and load the desired company. That code is usually produced by the Add Combo wizard if you select the option "Find record on the form":
    https://learn.microsoft.com/en-us/of...-box-selection
    https://support.microsoft.com/en-us/...b-b0f71a90c329
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #5
    Tonyb123 is offline Novice
    Windows 10 Office 365
    Join Date
    Dec 2023
    Posts
    8

    Save subform only

    Quote Originally Posted by June7 View Post
    Suggest you provide db for analysis. Follow instructions at bottom of my post.
    Many Thanks, Tony b
    Attached Files Attached Files

  6. #6
    Tonyb123 is offline Novice
    Windows 10 Office 365
    Join Date
    Dec 2023
    Posts
    8
    Hi Vlad, Thankyou for your response.
    Your description of the functionality is correct. I replaced the combo box with the "Find record on form" type. Moved the vba event for adding the company names to the main form Felds to "on change" event (After update has a Macro). Unfortunately the company table still gets a duplicated record on save. I hope what I am trying to do is possible with code or a restructure?

    Regards Tonyb.

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    You have Data Entry set to Yes?

    That means you create a new record each time.

    The worst named property of an Access Form.
    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

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Don't use code to set values of BOUND textboxes on main form. These should be for inputs by user for a new company record.

    Form DataEntry property is set to Yes. This means only new records can be input. That's what "data entry" means. Cannot view nor edit existing.
    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
    Tonyb123 is offline Novice
    Windows 10 Office 365
    Join Date
    Dec 2023
    Posts
    8

    Duplicate records

    Quote Originally Posted by Welshgasman View Post
    You have Data Entry set to Yes?

    That means you create a new record each time.

    The worst named property of an Access Form.
    Hi Welshgasman,
    I agree, "worst named property" Changed to NO and all good now.

    Thankyou for your response on this.

  10. #10
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    You should get rid of the lookup fields in your table.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

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

Similar Threads

  1. Replies: 3
    Last Post: 04-19-2022, 03:17 PM
  2. Replies: 4
    Last Post: 04-26-2020, 02:33 AM
  3. Replies: 39
    Last Post: 03-15-2017, 07:34 PM
  4. Replies: 1
    Last Post: 08-09-2012, 04:19 PM
  5. Replies: 14
    Last Post: 05-25-2012, 02:40 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