Results 1 to 2 of 2
  1. #1
    newbieX is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    111

    Fill existing data in form or add new to Access 2007 table if does not exist

    I have a relational database of cars (an example. My database is sensitive so I cannot use it but this example lays out the overall structure). The master table has basic information about the car. ID is unique and cannot contain duplicates.
    HTML Code:
    Table: MakeModel
    ID*          Model         Make          Model2
    HAS          Accord        Honda         Sedan
    HAC          Accord        Honda         Coupe
    HCS          Civic         Honda         Sedan
    HCC          Civic         Honda         Coupe
    HCH          Civic         Honda         Hybrid
    TCLE         Camry         Toyota        LE
    TCHLE        Camry         Toyota        Hybrid LE
    The user has a paper data entry form that he fills out when making a sale. I am creating a data entry form to populate the database after the data is handed to the data entry person. Because the form has over 100 possible fields, I have spilt the results into 2 separate tables so I can more easily manage the data. These tables have a one-to-one relationship with each other. They have a one-to-many relationship to the MakeModel table. ID and DateTime are primary keys for these two tables. Below are the field names for these two tables.
    Table: CarData
    ID*
    DateTime*
    SerialNumber
    Color
    Milage

    Table: BuyerData
    ID*
    DateTime*
    First


    Last
    My data entry form has all these fields in it. The problem is I am not sure how to write code to check to see if the ID exists in the MakeModel table, and if so, populate the fields ID, Model, Make, Model2 in the form with the data that exists in the table, otherwise add the new ID, Make, Model and Model2 to the MakeModel table. Right now I just get an error message telling me duplicate data exists. I have no code to include because I am totally new to this and do not even know where to begin. Any and all pointers are greatly appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Database is so sensitive can't even use the real field names?

    Apparently, breaking the table into two parts is not easier to manage. If it is truly a one-to-one relationship, then keep it as one table unless you will exceed 255 fields. If you do, then I suspect the real issue is data normalization. Even 100 fields is a lot and makes me wonder if it is normalized.
    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.

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

Similar Threads

  1. Import Excel data into existing Access Table
    By octsim in forum Import/Export Data
    Replies: 4
    Last Post: 10-24-2013, 07:21 AM
  2. Replies: 6
    Last Post: 06-14-2013, 05:43 PM
  3. Replies: 6
    Last Post: 09-10-2012, 07:19 AM
  4. Replies: 11
    Last Post: 07-24-2012, 07:50 PM
  5. Checking if data already exist in a Table
    By Phillsoft in forum Forms
    Replies: 1
    Last Post: 08-04-2011, 08:03 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