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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Repeat a query to fill a report

Status
Not open for further replies.

SirTECH

Technical User
Jul 24, 2005
42
CA
I have a table that holds various schedules. Each schedule has a different number of weeks in length. For example, say I've selected a schedule that is 3-weeks long. I want to generate a report that shows the schedule over a 52-week period. That means the query would repeat itself 18 times.
The query is...
SELECT * FROM tblSCHED WHERE SchedID="ScheduleA"
ORDER BY IIf([WkNUM]>=LineNUM(),0,1), WkNum

Note: The 'IIf' statement ensures that the schedule begins from a selected week number then loops back to the top. This is different than what I'm asking. Not only do I need it to loop, but repeat the cycle 'n' number of times.

The "tblSCHED" table has the following fields...
SchedID[tab](unique identifier for each schedule)
WkNum[tab](each week is sequentially numbered beginning at 1)
MonSHIFT[tab](shift code or null if day off)
TueSHIFT[tab](shift code or null if day off)
WedSHIFT[tab](shift code or null if day off)
ThuSHIFT[tab](shift code or null if day off)
FriSHIFT[tab](shift code or null if day off)
SatSHIFT[tab](shift code or null if day off)
SunSHIFT[tab](shift code or null if day off)
TotalWks[tab](total number of weeks in schedule)

To accomplish my task so far, I've created a report with 364 text boxes that are filled using VBA.

set RS = currentdb.openrecordset("qrySCHED")
for cnt = 1 to 52
[Tab]'fill boxes using me.box# = rs(field#)
[tab]rs.movenext
[tab]if rs.eof then rs.movefirst
next cnt


This works, but is slow. I would like to find a way for the query to be made to repeat itself rather that using VBA and manually creating 364 text boxes on a report.
Any suggestions?
Thanks.
 
there is no loop command in JET SQL but so VBA is probably way to go.
another option is
make another table
consisting of 18 ScheduleA's then join on that field. Should produce the number of weeks you want.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top