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.