Control a lable inside a report for many records

M

malibu

I have a report that displays all the invoices for clients that I
print out. The report is restricted to clients that want to receive it
through regular mail. On the report I want to control 2 labels. The
labels are "Invoice Paid" and "Credit Card Denied".

The table customers records if the credit card is denied or not. The
table lessons records if the invoice is paid or not.

I'm able to do this successfully on my other e-mail report since it's
restricted to a single client, but I don't know how to do this for
this report.

This is this code that works successfully in my e-mailed invoice,
however, I'm not sure how to modify it for the other report that lists
many clients in the same report.

I've tried may options such as the following, but the
creditcard_denied field can't be found.

If Me.CreditCard_Denied = True Then
lblCreditcardDenied.Visible = True
Else
lblCreditcardDenied.Visible = False
End If

Private Sub Report_Open(Cancel As Integer)
Dim bCreditCard As Boolean
Dim bInvoicePayed As Boolean


bCreditCard = DLookup("[CreditCard_Denied]", "Customers", "[StudentID]
=" _
& Forms![Add Lesson and Details]!StudentID)

bInvoicePayed = DLookup("[Invoice_Payed]", "Lessons", "[BillingID] ="
_
& Forms![Add Lesson and Details]!BillingID)


If bCreditCard = True Then
lblCreditcardDenied.Visible = True
Else
lblCreditcardDenied.Visible = False
End If

If bInvoicePayed = True Then
lblInvoicePayed.Visible = True
Else
lblInvoicePayed.Visible = False
End If

End Sub

Thanks very much.
 
T

Tom Wickerath

Hi Malibu,
I've tried may options such as the following, but the
creditcard_denied field can't be found.

Is this field included in the query that serves as the report's
recordsource? You should see this field in the Field List, in report design
view. Also, add a text box to your report, bound to this field. You can set
the visible property to No, but you should add a bound control for this
field, to help ensure that the report knows about this field.
Private Sub Report_Open(Cancel As Integer)

Use the Format event of the applicable section. For example:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

Do you really need the two calls to the domain aggregrate function DLookup?
Can you not include these fields in the query that serves as the recordsource
for the report?


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

malibu said:
I have a report that displays all the invoices for clients that I
print out. The report is restricted to clients that want to receive it
through regular mail. On the report I want to control 2 labels. The
labels are "Invoice Paid" and "Credit Card Denied".

The table customers records if the credit card is denied or not. The
table lessons records if the invoice is paid or not.

I'm able to do this successfully on my other e-mail report since it's
restricted to a single client, but I don't know how to do this for
this report.

This is this code that works successfully in my e-mailed invoice,
however, I'm not sure how to modify it for the other report that lists
many clients in the same report.

I've tried may options such as the following, but the
creditcard_denied field can't be found.

If Me.CreditCard_Denied = True Then
lblCreditcardDenied.Visible = True
Else
lblCreditcardDenied.Visible = False
End If

Private Sub Report_Open(Cancel As Integer)
Dim bCreditCard As Boolean
Dim bInvoicePayed As Boolean


bCreditCard = DLookup("[CreditCard_Denied]", "Customers", "[StudentID]
=" _
& Forms![Add Lesson and Details]!StudentID)

bInvoicePayed = DLookup("[Invoice_Payed]", "Lessons", "[BillingID] ="
_
& Forms![Add Lesson and Details]!BillingID)


If bCreditCard = True Then
lblCreditcardDenied.Visible = True
Else
lblCreditcardDenied.Visible = False
End If

If bInvoicePayed = True Then
lblInvoicePayed.Visible = True
Else
lblInvoicePayed.Visible = False
End If

End Sub

Thanks very much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top