Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query which will take one record and create multiple records 1

Status
Not open for further replies.

strangeryet

Programmer
Jul 8, 2004
159
US
Hello:
Does anyone have an idea as to how to accomplish this?
I need a query that will take information in a single record and possibly create several records from it based
on a series of check marks in the fields. And for example if a field like "Mon" has a check in it, we return the word "mon" instead of a check mark.

Here are some basic fields in the table:
RDate, ID, Count, Mon, Tue, Wed, Thur, Fri

RDate is a date field, Id and Count are numeric type fields and Mon, Tue, Wed, Thurs, Fri are Yes/No check fields.

One record might look like this:
12/18/2006, 14, 100, ,X, , , (where Tuesday is checked).
Another record might look like this:
12/19/2006, 15, 100,X,X,X, , (where mon, tues and wed are checked).

Using the two samples records above, when the query runs how can I have the result look like this:?
12/18/2006, 14, 100, Tue
12/19/2006, 15, 100, Mon
12/19/2006, 15, 100, Tue
12/19/2006, 15, 100, Wed


Thanks
I have IIF logic in a simpilar query to convert Checks to the text representation..ie "Tue", but I can't break into multiple records!
 
Have a look at UNION query:
SELECT RDate, ID, [Count], 'Mon' AS DayName FROM yourTable WHERE Mon = True
UNION SELECT RDate, ID, [Count], 'Tue' FROM yourTable WHERE Tue = True
...
UNION SELECT RDate, ID, [Count], 'Fri' FROM yourTable WHERE Fri = True

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top