Jack, I did build all the dates on the MAIN table-in fact almost ALL my
fields are built in the MAIN table. The below is way over my head. What
would you suggest as far as how to make this easier? Thank you.
:
I'll try this again....
If these are all fields in the same table, you have a data normalization
issue. Generally, each of these Sold Dates would be in a related table on
the 'many' side of the relationship.
That said, if you have 10 date fields in the same table, and you need to
find a record that has Jan 15th in any one of those 10 date fields, this is
what you need to do.
"SELECT * FROM tblname WHERE " & _
"[ID] = " & IDVariable & " And " & _
"(([datefield1] = #" & DateVariable & "#) Or " & _
"([datefield2] = #" & DateVariable & "#) Or " & _
"([datefield3] = #" & DateVariable & "#) Or " & _
"([datefield4] = #" & DateVariable & "#) Or " & _
"([datefield5] = #" & DateVariable & "#) Or " & _
"([datefield6] = #" & DateVariable & "#) Or " & _
"([datefield7] = #" & DateVariable & "#) Or " & _
"([datefield8] = #" & DateVariable & "#) Or " & _
"([datefield9] = #" & DateVariable & "#) Or " & _
"([datefield10] = #" & DateVariable & "#))"
This gets the first ID found (for the client), and assumes that DateVariable
is a variable of the Data datatype that holds the date you are trying to
find. It checks each of the date fields, and if one of them holds the same
data, adds that record to the SQL. You *should* wind up with one record, or
none, when its done.
As you can see, going through each record and running 10 checks for each
record is going to take a little while. Much much faster to use a related
table.
--
Jack Leach
www.tristatemachine.com
- "First, get your information. Then, you can distort it at your leisure."
- Mark Twain
:
We are an insurance company that has 5-10 sold dates per client. How in the
world do I (newbie) query on these dates? Product 1 sold Nov 15th, Product 2
sold Dec 15th, Product 3 sold Jan 15th. How would I query just the January
15th sale (which could be in sold date 3 or 2 or even 10)?