Sanies
06-27-2005, 09:53 PM
I am trying to setup a database for vehicle stock control.
Im not sure if I have gone about this the right way as I am new to this but thus far it is working correctly except for one annoying problem.
The database consists of so far
tblIAWVehicleDetails (Primary key "IAWvehicleID" autonumber)
tblIAWSellers (Primary key autonumber)
tblIAWBuyers (Primary key autonumber)
tblIAWStates (Primary key autonumber)
tblIAWStatus (Primary key autonumber)
tblIAWSafetyDetails (Primary key autonumber)
tblIAWSold (Primary key autonumber)
In the Vehicle Details table a stock number has to be manually added as this will be used for new stock as well as current stock (Number range from 100 - whatever) "IAWVehicleNo".
This table contains all relevent data with reguards to make, model, bodytype, color etc.
The sellers table contains the details of the seller Name, address, Phone, LicenceNo etc.
The Buyers table contains employee names.
The States table contains all Australian states.
The Status table contains current vehicle status Retail, Wholesale, Wrecking etc.
The Sold table contains the details of the person who purchased the vehicle if sold.
The Safety details table contains a safety checklist for pre purchase inspections eg: Headlights yes/no checkbox, Headlight text field for any extra info.
It also has a field for a safety Certificate No once the vehicle is checked and recieves a Safety cert.
The forms are setup as
frmIAWVehicleDetails
frmIAWSellers Subform
frmIAWVehicleSafetyDetails
frmIAWVehicleSafetyDetails Subform
The Vehicle Details,Sellers,Sold & SafetyDetails tables all have the IAWVehicleID & IAWVehicleNo Fields but when the details are entered through the forms the IAWVehicleNo which is the manually entered number only updates to the tblIAWVehiclesDetails but the other IAWVehicleNo fields in the other tables remain blank.
Any advice or help would be greatly appreciated.
neileg
06-28-2005, 06:46 AM
Which field are you using to link your tables? I assume it's IAWvehicleID. In this case, why do you need to populate all these tables with IAWVehicleNo? You can look it up from tblIAWVehicleDetails any time you need it.
ScottGem
06-28-2005, 09:01 AM
There are a number of things unclear about your structure. The tables you listed seem ok, though I would have on table for people with a field to identify them as a buyer or seller. But what's missing is the tables to tie things together. For example there should be a Sales table:
SalesID (PK Autonumber)
IAWvehicleID (FK)
SellerID (FK)
BuyerID (FK)
SalesDate
Price
Another issue is that the ONLY thing you need form the Vehicles table in the other tables is the PK as a foreign key. Any other info would vioalte normalization rules. If you need to pull any info fromt he Vehicles table you do so in a query by joining the tables on the ID fields.
Sanies
07-21-2005, 05:21 AM
Sorry for the late reply but I have been away for a bit.
I will try to explain in a bit more detail what I have done and what I am trying to achieve.
The database consists at this point of 8 tables thses are:
tblIAWBuyers - BuyerID PK autonumber - Surname, FirstName etc
tblIAWSellers - SellerID PK autonumber - Surname, FirstName etc
tblIAWEmployees EmployeeID PK autonumber - EmployeeName
tblIAWVehicleDetails - IAWvehicleID PK autonumber - IAWVehicleNo, Make, Model, ChassisNo, EngineNo etc
tblIAWvehcileSoldDetails - IAWvehicleSoldID PK autonumber - Make, Model, ChassisNo, EngineNo etc
tblIAWSafetyDetails - IAWSafetyID - PK autonumber - SafetyNo, SafetyDate
tblIAWStates - StateID - PK autonumber - Abreviated Australian States
tblIAWStatus - StatusID - PK autonumber - Retail, Wholesale, Wrecking etc
These tables are what I believe I will need for this setup and I will expalin what it is I am trying to achive.
*tblIAWvehicleDetails - When we purchase a vehicle it is given this number numerically from the stockbook and then we also fill out all the vehicle particulars including color, trim, mileage,enginesize, transmission, current registration Number etc etc etc.
IAWVehicleNo in tblIAWvehicleDetails is our stock number for the particular vehicle eg: 7654
This is a unique number to each car but we must be able to enter a particular number in this field to coincide with our paper stockbook as we will be using this for not only new vehicles but ones we currently have or have had - going back to the year 1999.
*tblIAWSellers - We also fill out the sellers details including licenceNo, Name, Address, DOB, etc etc etc.
*tblIAWvehicleSoldDetails - If we do happen to sell a vehicle that we have repaired the details would sometimes match the details of the vehicle we purchased but not always. eg we buy vehicleNo 7654 which is white and has engine no abc123 and is automatic but the engine is faulty and not servicable and has panel damage. We might repaint this vehicle red and fit a new engine to it with engine no xyz789 with a 5spd gearbox. Therefore we need to have this table to save the details of vehicleNo 7654 when it is sold.
*tblIAWBuyers is the details of the purchaser Name, Address, DOB, etc etc etc.
*tblIAWSafetyDetails - This has been setup as a safety checklist similar to a 50 point inspection in preperation to a vehicle being sold.
It has Yes/No checkbox's and text boxes for each checkbox eg Front Brakes (tick checkbox) Machine front rotors and fit new pads in textbox.
tblIAWStates, tblIAWStatus & tblIAWEmployees are Combo boxes on the forms.
There are 6 forms 3 main, 3 sub
*frmIAWVehicleDetails - bound to tblIAWvehicleDetails
*frmIAWSellers Subform - bound to tblIAWSellers
*frmIAWVehicleSoldDetails - bound to tblIAWvehicleSoldDetails
*frmIAWBuyers Subform - bound to tblIAWBuyers
*frmIAWSafetyDetails - bound to tblIAWVehicleSoldDetails - Shows a few details inc IAWVehicleNo, make, Model etc
*from IAWSafetyDetails Subform - bound to tblIAWSafetyDetails
What i need to achive is to link all these tables together with the Vehicle No that we input.
Secondly I would like to open the purchase details form and fill in the vehicle and seller details and then be able to open the sold form and have the same vehicle details visible that are already in the purchase table but be able to modify certain entries to coincide with any changes made by us to the vehicle and save the updated info in the sold table without editing the purchase details. I need to have a copy of both records for each vehicle.
I have partly designed what I am trying to do and would be happy to email it so that you can actually see it rather than viualise it as there are quite a few entries in each table and it would take quite a while to type them all here but I believe i have given you all the relavent info.
Hopefully I have explained myself and what I am trying to do well enough but feel free to ask any questions and hopefully you guys can help me out.
I understand that setting up the correct relationships is the key to getting this working correctly.
Thanx again
neileg
07-21-2005, 05:40 AM
While you could use the vehicle number to link the tables, I suggest you use an autonumber instead. This will make it easier to open a new record and then enter your vehicle number. If you set your vehicle number field to Indexed, no duplicates, this will prevent the same number being entered twice.
Re-read Scott's advice.
ScottGem
07-21-2005, 06:41 AM
Well my original advice still stands. You should combine the buyers and sellers tables into one table with a flag to indicate buyer or seller. I would also put employees into this one table, but I would add an Employee details table since there will probably be additional data about employees that you wouldn't keep on buyers and sellers.
You also have some normalization issues. You have duplication between the Vehicle Details table and the Sold Details. Any data that is already in Vehicle Details should NOT be in Sold Details. All you need from Vehicle Details in Sold Details is the VehicleID as a PK. I would also use an autonumber PK rather then Vehicle ID on the vehicle. Typos can occur when entering those numbers and you could have problems when correcting the typos.
States and Status appear to be lookup tables and I would rename them them with a tlu prefix instead of tbl to differentiate them. I would also add lookup tables for Make, Models and other details. I would then add a Vehicle equipment table like so:
tblIAWVehicleEquipment
VehicleEquipID (PK Autonumber)
IAWVehicleID (FK)
EquipmentTypeID (FK)
Since all cars don't have the same equipment you want to use a separate table to list the euipment they have.
You should be adding a repair table. This table would indicate any repairs made to a vehicle rather then putting them in the Sold Details.
Again, you would be better off using an autonumber as the PK for the Vehicle. You then include that field as an FK in your related tables.
What you should do is use subforms. Your main Purchase form would be bound to the Vehicle table with a subform for the Equipment table I suggested. any work done on the vehicle would be detailed in the Repair table which could be entered as the work is completed or when the vehicle is sold.
Sanies
07-21-2005, 02:37 PM
Thanx again for the reply and I will have a go at the restructuring as you suggested.
The employees table is simply the employee name who purchased the vehicle or sold the vehicle so I will also rename this table to tlu as well as I know that no additional info about employees is needed.
Thanx again for the reply and I will let you know how I go with it.