Re: Please Look at this query
  Home FAQ Contact Sign in
microsoft.public.access.queries only
 
Advanced search
POPULAR GROUPS

more...

 Up
Re: Please Look at this query         

Group: microsoft.public.access.queries · Group Profile
Author: Allen Browne
Date: Jul 17, 2007 03:07

Jaybird, this table really, really, really needs to be redesigned.

Whenever you see repeating fields such as [Part Number 1], [Part Number 2],
... it always means that you need a related table where you can store many
records instead of having many fields in the one table.

One order can contain many line items. That means you need 2 tables:
- an order header table, with fields such as OrderNumber, OrderDate,
CustomerID.
- an order detail table to hold the line items. Fields such as Quantity,
PartNumber, UnitPrice.

For an example of how to build such a table, open the Northwind sample
database that installs with Access. Open the Relationships window (Tools
menu.) You will see an example of how to set up the Order and OrderDetails
tables.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Jaybird" wrote in message
news:E2078205-F73E-427D-A20D-2E7A791B433C@microsoft.com...
> Here's my query:
>
> SELECT DISTINCT Tools.[Tool Number] as [Tools/Tool Number], [Order
> Entry].[Tool #] as [Order Entry/Tool #], [Order Entry].[Part Number1],
> [Order
> Entry].[Part Number 2], [Order Entry].[Part Number 3], [Order Entry].[Part
> Number4]
>
> FROM [Order Entry] INNER JOIN Tools ON ([Order Entry].[Part
> Number1]=Tools.[Tool Number]) Or ([Order Entry].[Part Number
> 2]=Tools.[Tool
> Number]) Or ([Order Entry].[Part Number 3]=Tools.[Tool Number]) Or ([Order
> Entry].[Part Number4]=Tools.[Tool Number]) Or ([Order Entry].[Tool
> #]=Tools.[Tool Number])
>
> WHERE (((Tools.[Tool Number]) Like "*" & [Search Criteria] & "*"))
> ;
>
> What I think this is doing is looking through the Tools table under Tool
> Number, and through the Order Entry table under Tool #, Part Number1, Part
> Number 2, Part Number 3, Part Number4 and searching for matches with the
> Search Criteria string. It's supposed to search for matches in these
> fields
> of these two tables with the search string that I input. I just wanted to
> make sure that this is doing what I think it's doing and that I'm not
> overlooking something. Can anybody tell me?
>
> I'm also interested in integrating this search query into a form that will
> bring up the matches for verification, and if there are none, provide a
> way
> to add new records to the Tools table. Any idea?
>
> I'd also like to know if this posting makes any sense to you at all...
> --
> Why are you asking me? I dont know what Im doing!
>
> Jaybird
no comments
diggit! del.icio.us! reddit!