I'm sure it's obvious to you, faced with this problem, that your data are
not normalized. One should never be puttting the same data in "separate"
fields that are identified by "number" labels. That is not how a database
works best.
To do what you want with the data structure that you're using, you'll need
to create two separate queries.
The first query must "normalize" your data. It is a union query that puts
all three data field combinations into a "single field":
SELECT T.[Name], T.C1 AS IDName, T.C1Total AS IDTotal
FROM Tablename AS T
UNION ALL
SELECT TT.[Name], TT.C2, TT.C2Total
FROM Tablename AS TT
UNION ALL
SELECT TTT.[Name], TTT.C3, TTT.C3Total
FROM Tablename AS TTT;
Create and save this query; call it qryUnion.
Then create a second query that will be used to find the data that you wish:
SELECT Q.[Name], Q.IDName, Q.IDTotal
FROM qryUnion AS Q
WHERE Q.IDName = [Enter the text string to find:];
This second query will find the desired info for you.
Also, I note that you're using Name and Date as the names of fields in your
table. This is not a good practice because Date is the name of a VBA
function, and Name is the name of a property for many objects. Using such
reserved words can confuse ACCESS. For more info on which words should not
be used as field names, control names, etc., see this Knowledge Base
article:
ACC2002: Reserved Words in Microsoft Access
http://support.microsoft.com/default.aspx?scid=kb;en-us;286335
--
Ken Snell
<MS ACCESS MVP>
jeanne said:
I am looking for away to search the table below for "RGRND" and if possible
return the corresponding "Total" Unfortunately "rgrnd" does not always fall
into the same column.
For instance under ps it would return 380.
Any ideas?
Name Date C1 C1TOTAL C2 C2TOTAL C3 C3TOTAL C4 C4TOTAL
PS 10/18 OT 420 REG 380 RGRND 380 OTGRND 420
DS 10/18 REG2 2004 RGRND 2004
SS 10/18 REG 15 OT2 1227 OTGRND 1227 RGRND 15
BS 10/18
Thanks
Jeanne