Printing Access Report from VB

JerryEng
11-27-2002, 01:12 PM
I have a Job Labor report based upon a query in Access that I'm trying to print from VB. The report displays total labor hours and labor cost (hours * cost) for the specified job number. The total hours are grouped by month (I told the query wizard in Access to generate a summary query).

I can print the report from VB if I specify only the job number:
appAcc.DoCmd.OpenReport "rptJobCostLabor", acViewNormal, , "[TimeSlips.JobNum] =" & strJobNum

What I would like to do is also limit the date range. There is a field in the query "Slip Date By Month: Format$(TimeSlips.SlipDate,'mmmm yyyy')". If I set the criteria of this field to "=?" in the Access query, I can run the report from Access and when I'm prompted to 'Enter Parameter Value ?', I can enter the date as "November 2002" and only labor for that month is shown.

The trouble is, I can't seem to call that field (Slip Date By Month)from VB. Ideally, I would like to enter a date range, e.g.
[TimeSlips.SlipDate] >= #date1# AND [TimeSlips.SlipDate] <= #date2#

Can this be done or am I going about the whole thing wrong?

holtzy
11-27-2002, 02:19 PM
I think it can be done. Are you needing to pass the date variable from VB to Access?

JerryEng
11-27-2002, 02:32 PM
Yes, I need to pass the date range from VB. The user will pick start and end date using datepickers.

holtzy
11-27-2002, 02:57 PM
The one way I can think to do it is this. When they pick the date, use an update statement to write the date to a table in the Access database. Then have the Access report automatically pull from that table.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum