I started to reply yesterday when the lights went out.
I tried the solutions you gave me. I re-structured the databases so no
field
names were also used as the table name. I made a new autonumber primary
key
for MSDS. The Chemicalname field is now indexed with no duplicates
allowed.
The CAS database is still keyed on the same field, but it is renamed
IdCAS.
That part's good.
I tried the new query with the third table. I think I entered everything
correctly, but I only get a blank table for a response.
Before I read the latest response I tried using a third table with all
fields from both of the other tables. I was able to make a query and
design a
DAP that worked (sort of) from that. The thing I noticed is the "Filter
Toggle Button" was highlighted. When I clicked on that with a record that
had
missing data the data would show up. I went back to the original DAP and
inserted the navigation toolbar. I copied and pasted the filter toggle
button
to the record area of the page, then deleted the toolbar again. Now when a
record has missing data I can click on the filter toggle button 5-10 times
and the data appears. It's kind of sloppy, but for now it works. Does that
shed anymore light on this problem?
By the way I said that DAP sort of worked because the whole page needs to
be
filtered to the pull-down at the top that selects the substance we want
the
information about. Every thing worked except that, so I went back to the
original page. With the new page I still had missing data but it was after
100-200 records, not just 30.
:
Then my first suggestion would be that you use an Autoincrement ID as the
primary key for your MSDS table. This is not mandatory but using names
as
primary key is asking for trouble because you cannot change the name
later.
Also, using MSDS and CAS both as the name of the table and the name of
one
of the field can lead to confusion, too.
Create a table MsdsCas with the following three fields:
IdMsdsCas --> the primary key for this new table
Msds --> the foreigh key for the table MSDS
Cas --> the foreigh key for the table CAS (by the way, would not
be a
bad idea to rename it IdCas)
You can also use Msds and Cas to roll out a primary key with two fields
(Msds and Cas) but again, this may could more confusion than help.
Finally, you select clause will be something like:
Select M.Msds, M.Manufacturer, ...., C.Cas, C.ChemicalName,
C.Description, ...., MC.IdMsdsCas
From Cas as C inner join (MSDS as M inner join MsdsCas MC on M.Msds =
MC.Msds) on C.Cas = MC.Cas
This is much simpler.
Also, after a second reading of your previous message, I see that you
didn't
provide a definition for the table (or query?) that you call «
[MSDS/CAS] ».
If necessary, modify the above query to take care of this table.
S. L.
No. I have used several database programs, but I am fairley new to
Access.
I
had trouble setting up the third table so I went this route instead. I
would
like to try the third table.
:
Excerpt for the unusual high number of Rigth Join, your piece of code
looks
perfectly valid to me.
Is there is any particular reason that you must have 10 CAS fields in
the
MSDS table (and linking them with Right Join) instead of a more usual
third
table with ordinary Inner Join?
S. L.
Sylvain,
This first part is the main query I am working with. The second part
is
the
query for the CAS numbers. The third part is the VB code from the
DAP.
Seems
like a big file to include here, but there is nothing proprietary
about
it.
It's too long to post. I'll try sending it separate.
---part 1---
SELECT DISTINCT [MSDS/CAS].CHEMICALNAME, [MSDS/CAS].DESCRIPTION,
[MSDS/CAS].MSDS, [MSDS/CAS].MANUFACTURER,
[MSDS/CAS].PRODUCTNAMENUMBER,
[MSDS/CAS].CURRENTUSE, [MSDS/CAS].[DISPOSAL DATE],
[MSDS/CAS].PURCASEDATE,
[MSDS/CAS].LOCATION, [MSDS/CAS].TYPE, [MSDS/CAS].STATE,
[MSDS/CAS].HEALTH,
[MSDS/CAS].FIRE, [MSDS/CAS].REACTIVITY,
[MSDS/CAS].SPECIALPRECAUTIONS,
[MSDS/CAS].COMMENTS, [MSDS/CAS].PDF, [MSDS/CAS].CASNUMBER1,
[MSDS/CAS].CASNUMBER2, [MSDS/CAS].CASNUMBER3, [MSDS/CAS].CASNUMBER4,
[MSDS/CAS].CASNUMBER5, [MSDS/CAS].CASNUMBER6, [MSDS/CAS].CASNUMBER7,
[MSDS/CAS].CASNUMBER8, [MSDS/CAS].CASNUMBER9,
[MSDS/CAS].CASNUMBER10,
[CAS
Query1].CHEMCIAL, [CAS Query2].CHEMCIAL, [CAS Query3].CHEMCIAL, [CAS
Query4].CHEMCIAL, [CAS Query5].CHEMCIAL, [CAS Query6].CHEMCIAL, [CAS
Query7].CASNUMBER7, [CAS Query7].CHEMCIAL, [CAS Query8].CHEMCIAL,
[CAS
Query10].CHEMCIAL
FROM [CAS Query10] RIGHT JOIN ([CAS Query9] RIGHT JOIN ([CAS Query8]
RIGHT
JOIN ([CAS Query7] RIGHT JOIN ([CAS Query6] RIGHT JOIN ([CAS Query5]
RIGHT
JOIN ([CAS Query4] RIGHT JOIN ([CAS Query3] RIGHT JOIN ([CAS Query2]
RIGHT
JOIN ([CAS Query1] RIGHT JOIN [MSDS/CAS] ON [CAS Query1].CAS =
[MSDS/CAS].CASNUMBER1) ON [CAS Query2].CAS = [MSDS/CAS].CASNUMBER2)
ON
[CAS
Query3].CAS = [MSDS/CAS].CASNUMBER3) ON [CAS Query4].CAS =
[MSDS/CAS].CASNUMBER4) ON [CAS Query5].CAS = [MSDS/CAS].CASNUMBER5)
ON
[CAS
Query6].CAS = [MSDS/CAS].CASNUMBER6) ON [CAS Query7].CAS =
[MSDS/CAS].CASNUMBER7) ON [CAS Query8].CAS = [MSDS/CAS].CASNUMBER8)
ON
[CAS
Query9].CAS = [MSDS/CAS].CASNUMBER9) ON [CAS Query10].CAS =
[MSDS/CAS].CASNUMBER10;
---part 2---
SELECT DISTINCTROW CAS.CAS, CAS.CHEMCIAL, MSDS.CASNUMBER9
FROM CAS INNER JOIN MSDS ON CAS.CAS = MSDS.CASNUMBER9;