Results 1 to 3 of 3
  1. #1
    accessrmv is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2015
    Posts
    2

    Update Table Record from Form Command Button Code Help

    I currently am setting up a database for a small business. At the moment I am just building the first part to include our client data including a form that has buttons already setup to add record, clear the form, and search the table for a record and then fill the form with the data.

    The next step that I am trying to do is add a button that will update the table if the Client ID (primary key) currently exists in the table

    Name of the table is ClientInfoTable
    Name of the form is ClientInfoForm

    the form currently contains bound text boxes for client contact info including one combo box for active/terminated form field name are listed below



    ClientID
    ClientContactFirstName
    ClientContactLastName
    PhoneNumber
    Email
    Address

    Combo box = ClientStatus

    Any help with the code to add behind the button would be greatly appreciated

    *EDIT* Forgot to mention that the ClientID field would always need to remain unedited. I was thinking of using Me.ClientID.Locked = True on the search button and then a False on the clear button but not sure if this is the best solution

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    The client ID should be a text field (your internal client numbering system) your table should also include an autonumber primary key field that is independent of the internal client number because client numbers can change over time (one company buys out another for example). If your client ID is already an autonumber then you can't update it regardless of what you do but I suspect that's not the case.

    Are you determined to do this with a bound form? you would likely have to do a dcount function in the on exit property of the internal client number to check to see if it already exists in any record that is not the current record.

  3. #3
    accessrmv is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2015
    Posts
    2
    I would like to keep it in the same bound form if that is possible

    My thought was you would be able to use the search function and then if any fields were missing to you need to update a phone number or email you could just delete and re key and the use this update key to change the table.

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

Similar Threads

  1. code to open table from Command Button
    By DMJ in forum Database Design
    Replies: 1
    Last Post: 02-20-2014, 12:33 PM
  2. Replies: 13
    Last Post: 12-17-2012, 07:52 PM
  3. Replies: 1
    Last Post: 12-03-2012, 02:50 PM
  4. Replies: 12
    Last Post: 03-14-2012, 10:54 AM
  5. Form/report command button code
    By max3 in forum Forms
    Replies: 1
    Last Post: 08-26-2009, 02:18 AM

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