D
datamerc
Hi,
I'm struggling trying to get this to work. I am building report
(Access 2003) to generate invoices for storage spaces. There are 2
tables (customers, storage_spaces) that it pulls from; each customer
can have multiple storage spaces that are paid once a year.
In the detail section of the report, I need to have a line generated
for each storage space for each year that it may be overdue up to the
current year (along with the corresponding storage fee). For example,
a customer with 2 storage spaces may have an invoice that looks like
this:
Space #101 for 2005... $300.00
Space #101 for 2006... $300.00
Space #305 for 2004... $500.00
Space #305 for 2005... $500.00
Space #305 for 2006... $500.00
The following code that I have will print out a line (into a label
field), but I have had to include the "vbCrLf" if I want to see all the
lines (rather than just the last record). Because there could be many
years that a storage space is overdue, a label field doesn't work well
because it has a defined height. For some reason though, the fee for a
single space will only print once. Here is the all the code I have for
the report:
I'm struggling trying to get this to work. I am building report
(Access 2003) to generate invoices for storage spaces. There are 2
tables (customers, storage_spaces) that it pulls from; each customer
can have multiple storage spaces that are paid once a year.
In the detail section of the report, I need to have a line generated
for each storage space for each year that it may be overdue up to the
current year (along with the corresponding storage fee). For example,
a customer with 2 storage spaces may have an invoice that looks like
this:
Space #101 for 2005... $300.00
Space #101 for 2006... $300.00
Space #305 for 2004... $500.00
Space #305 for 2005... $500.00
Space #305 for 2006... $500.00
The following code that I have will print out a line (into a label
field), but I have had to include the "vbCrLf" if I want to see all the
lines (rather than just the last record). Because there could be many
years that a storage space is overdue, a label field doesn't work well
because it has a defined height. For some reason though, the fee for a
single space will only print once. Here is the all the code I have for
the report:
Code:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim curr_year
Dim years_overdue
Dim x 'counter for do loop
Dim yr_print 'year printed on the invoice line item
Dim annual_fee As Currency
curr_year = Format(Date, "yyyy")
x = 1
'Calculate the number of years overdue
years_overdue = curr_year - Me.txt_last_year_paid
'Loop through all previous unpaid years
Do While x < years_overdue + 1
yr_print = Me.txt_last_year_paid + x
Me.lbl_space.Caption = Me.lbl_space.Caption & "Space #" &
Me.txt_space.Value & " for " & yr_print & vbCrLf
Me.lbl_fee.Caption = Me.lbl_fee.Caption & Me.txt_fee.Value
& vbCrLf
x = x + 1
Loop
End Sub
[END CODE]
Can someone please help me figure out how to get this report to print
out a line for every year that a storage space is overdue up to the
current year (this can be x number of lines) and have this be in a
field with no predefined height. Thank you in advance.