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

Display bitmap in report based on checkbox value in query

Status
Not open for further replies.

dar149

MIS
Mar 5, 2002
117
US
I have a form that displays a bitmap based on the value of a checkbox. The following code works on the form:
If [SAF-A02-000] = yes Then
[OLERed].[Visible] = 0
Else
[OLERed].[Visible] = -1
End If

However, I am now trying to display the bitmap in a report only if the checkbox value in the query is yes. I can't get the report to look at the checkbox value in a query.

Any suggestions?

Thanks,
Debbie
 
On the Report's OnFormat event is where you want to put your code. And it would look just like the code in your form. Make sure you have the checkbox as a control on the form (set its visible property to False)
 
Hi,
I tried what you suggested, but because the report is based on a query (I have a calculation so I need to base on the query) and not the form, I can't get the code to work. I keep getting an object required error. Also, the result of the condition is always empty.

Thanks for any help.....
 
I'm assuming that the query contains the checkbox value and that the report contains the bitmap. If so, then the logic is the same as the form. Why don't you post your code and your SQL statement for the query.
 
Hi,
Yes, the query contains the checkbox value and the report contains the bitmap. Here's the SQL statement of the query:

SELECT Operators.EmployeeNo, Operators.NameLast, Operators.NameFirst, Operators.NameMI, Operators.Photo, Operators.[SAF-A01-000], Operators.[SAF-A01-000-Date], Operators.[SAF-002-LP], Operators.[SAF-002-LP-Date], Operators.[SAF-A02-000], Operators.[SAF-A02-000-Date], Operators.[SAF-A03-000], Operators.[SAF-A03-000-Date], Operators.[SAF-A04-000], Operators.[SAF-A04-000-Date], Operators.[SAF-A05-000], Operators.[SAF-A05-000-Date], Operators.[SAF-A06-000], Operators.[SAF-A06-000-Date], Operators.[SAF-003-LP], Operators.[SAF-003-LP-Date], Maximum([SAF-A01-000-Date],[SAF-002-LP-Date],[SAF-A02-000-Date],[SAF-A03-000-Date],[SAF-A04-000-Date],[SAF-A05-000-Date],[SAF-A06-000-Date],[SAF-003-LP-Date]) AS [Maximum Date]
FROM Operators;
 
Ok. I created a quick table that contained one field (SAF-A02-000) and defined the field as a Yes/No type. Then I created a report based on the table (query...same results). I then inserted a bmp (OLERed.bmp) (picture) on the report, named it "OLERed" and inserted the field "SAF-A02-000" on the report and changed its visible property to false.

So I have 2 things on the report:
SAF-A02-000
OLERed

On the OnFormat event of the Design section I added the following code and it worked like it was supposed to. So, your code should look something like this:

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

    If (SAF-A02-000) Then         'If True, then item checked
        OLERed.Visible = False    'Make bmp invisible
    Else
        OLERed.Visible = True     'Make bmp visible
    End If
    
End Sub
 
It works perfectly!!

Thanks for all the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top