Results 1 to 2 of 2
  1. #1
    JohnnyOz is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    1

    Question Form to add/edit rows in a table with a multi-field primary key

    I'm very new to Access and I want to do something I hope is quite simple. I have just one table, which has a three-field primary key. I want to create a form which allows easy adding of rows and updating of rows without using the forward/backward buttons at the bottom. I want to use combo boxes and a 'Save' button.

    The problem is that I want the three key fields to be at the top of the form as combo-boxes. If values are selected which correspond to an existing row I want the rest of the form fields filled with the row data and for the row to be updated by means of the 'Save' button. If the three combo boxes are set to values which don't correspond to an existing row I want the remaining fields to be blank and for the row to be created when the 'Save' button is pressed.

    Quite simple, really, but I can't seem to get it to work. I have set the table up with the required key and I have placed the combo boxes on the form with acceptable values in a list. The problem is that I can't get the form to update when the combo boxes are changed. It seems easy enough when there's just one field in the primary key, but when I try it with my three-field primary key I get errors saying that I am attempting a CancelUpdate without having previously issued an Edit or AddNew, or something like that.



    Any ideas?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,923
    Why do you feel you need all three fields in the PrimaryKey?
    (RG for short) aka Allan Bunch Previous MS Access MVP - WinXP Pro, Win7 Pro Win10 Pro - acXP, ac07, ac10, ac13
    How to mark the thread as Solved!
    Teaching is not filling a bucket but lighting a fire.
    Borrowed quote..."Docendo discimus"

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

Similar Threads

  1. Replies: 3
    Last Post: 10-30-2013, 11:42 AM
  2. Updating Table field from Form
    By Kunuk in forum Access
    Replies: 0
    Last Post: 02-26-2009, 11:41 PM
  3. Replies: 0
    Last Post: 08-25-2008, 12:17 PM
  4. Multi-select listbox and update flag in table
    By Suresh in forum Programming
    Replies: 0
    Last Post: 12-19-2007, 01:04 AM
  5. Most reliable way to edit form data in VBA...?
    By samalter in forum Programming
    Replies: 0
    Last Post: 06-23-2006, 12:39 PM

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