Chris Cote
Chris Cote

Reputation: 11

Issues trying to add record to MS Access table in PHP

I have 3 tables in my Access database - Customers, Computers, and Issues for a computer repair PHP application. The definitions for the tables are as follows:

Customers - ID (Autonumber), LastName, FirstName, Telephone
Computers - ID (Autonumber), Model, LogIn, Password, CustomerID (foreign key)
Issues - ID (Autonumber), DateRequested, CustomerID (foreign key), ComputerID (foreign key), Issue

I have a query that adds a customer record followed by a query to retrieve the ID of this new record. Next, I have a query which adds a new computer record, using the customer ID. Again, I have a query to retrieve the ID of this new record.
Both of these pairs of queries work fine. When I try to insert a new record into the Issues table using the 2 IDs from the previous retrievals, I get an error saying "Microsoft Access can't append all the records in the append query due to key violations. Here is the query I am trying to run:

INSERT INTO Issues (DateRequested, CustomerID, ComputerID, Issue, ItemsIncl, ImageName) VALUES (#1/14/2015#, 1, 1, 'Trouble with monitor.', '', 'none.gif')

I have check both the Customer and Computer tables, and they both contain ID with value of 1. I have also tried changing the date to be included within quotes and get the same problem.

I would appreciate anyone who can help me on this.

Chris

Upvotes: 1

Views: 66

Answers (1)

Chris Cote
Chris Cote

Reputation: 11

I just figured out one of the issues. I was looking at the wrong set of keys. I also have, within the Issues table, a field for the status which is a number from 1-6. I then added a relationship with the Status table, but I had forgotten to add the different status values.

Sorry about that everyone.

Upvotes: 0

Related Questions