Jump to content

Recommended Posts

Posted

For arguments sake in this case I want to create a database in Access for all my assets.

 

I have a table with all the makes in and have one with all the models in. The models on looks up to the makes one and pulls that information down.

 

I then want to create the assets table. I want to be able to select the make and in the model field I want it only to display the items that are under the model I selected in the previous field.

 

How do I do it?

 

For arguments sake I have 10 makes and 50 models. I will then say have some 2000 assets.

 

Can someone help please?

 

Thanks in advance.

Posted

I was only using asset management as an example to try and explain what I was trying to achieve.

 

I will have a go myself and will have a read of that link.

Posted (edited)

Are you new at databases? I would have three tables - one for the make and model (tblMakeModel) one for the Make (tblMake) and one for the Model (tblModel):

 

tblMakeModel:

tblMakeMode_lID - auto num (pk)

tblMakeMode_MakeID - num (fk)

tblMakeMode_ModelID - num (fk)

 

tblMake:

tblMake_ID - auto num (pk)

tblMake_Make - text

 

tblModel:

tblModel_ID - auto num (pk)

tblModel_Model - text

 

PK - Primary Key

FK - Foreign key

 

This would help save memory space and repeating your self.

The SQL would look something like:

select tblMake_Make from tblMake left outer join tblMakeModel 
tblMake_MakeID = tblMakeModel_MakelID
left outer join tblModel
tblModel_ModelID = tblMakeModel_ModelID 
where tblModel_ID = @ModelID

 

Note that the @ModelID is the variable you want to look up.

 

If you're not sure what the above does here it is rewritten slightly differently:

select tblMake_Make from tblMake, tblMakeModel, tblModel
where
tblMake_MakeID = tblMakeModel_MakelID and
tblModel_ModelID = tblMakeModel_ModelID and
tblModel_ID = @ModelID

Edited by Pashers
Posted

Or a lazy/quick dirty way to do it (I would not recommend this as it means duplicating yourself but if it suites your needs and makes your life easier):

tblMakeAndModel

tblMakeAndModel_ID (PK)

tblMakeAndModel_Make (text)

tblMakeAndModel_Model (text)

 

select tblMakeAndModel_Make from tblMakeAndModel where tblMakeAndModel_Model = @variable[/Code]

Posted
If using Access there are a set of GUI options that will 'filter' available fields based on selections in other fields. I going to take a punt and say you are wanting to use combo boxes for these fields?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...