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

Dynamic Image in Report 2

Status
Not open for further replies.

PaulLizer

Technical User
Feb 1, 2008
5
US
Hello everyone. I have a table, "ShortTermObsolescence" setup with a column labeled "Status". It can only have values of "Red", "Yellow", or "Green". I have a report "Project" and when I run it I dont want the Status to show up as characters "Red", "Yellow", or "Green" I want to to show up as an image that is a circle that shows the corresponding color. This is the VB that I have setup within "Project" using build an Event.

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

    If Table!ShortTermObsolescence!Status = "Red" Then
    Me.Status_Image.Picture = "C:\redcircle.JPG"
    ElseIf Table!ShortTermObsolescence!Status = "Yellow" Then
    Me.Status_Image.Picture = "C:\yellowcircle.JPG"
    ElseIf Table!ShortTermObsolescence!Status = "Green" Then
    Me.Status_Image.Picture = "C:\greencircle.JPG"
    End If
    
End Sub

How do I set it up so that works? Am I on the right track? I appreciate any help anyone can give me. I havent seen this type of problem on the internet its been difficult for me to research.
 
If the images aren't too big, you could put them in the report where they are supposed to go and then change your if statements to visible=true or visible=false

Code:
If Table!ShortTermObsolescence!Status = "Red" Then 
  Me.redcircle.visible=true
  Me.yellowcircle.visible=false
  Me.greencircle.visible=false
ElseIf...
 
I think (I might be wrong) that it would be faster to create three image controls and stack them up on top of each other. This worked form me.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Select Case Me.strColor
Case "Green"
Me.Image1.Visible = True
Me.Image2.Visible = False
Me.Image3.Visible = False
Case "Yellow"
Me.Image1.Visible = False
Me.Image2.Visible = True
Me.Image3.Visible = False

Case "Red"
Me.Image1.Visible = False
Me.Image2.Visible = False
Me.Image3.Visible = True

End Select
End Sub
 
I posted late same idea as sxschech
 
I appreciate your help sxschech but I would get Complie Error Method or Data Member not found. i couldnt get the elseif one to work.

MajP in your example how do I pull the information from my table's status column?
 
Sorry about the errors, wrote the code quickly to give an idea.
 
I assumed that this is a record in a bound report and that you have this field in the report, if not I do not understand what you are trying to do with the table.

this assumes a bound table to a report with field in the bound table called status

select case me.Status
 
It is a report being created from a table. I dont want to report to display Yellow, Red, or Green characters that are in the table. Instead I want the report to show yellow, red, or green circles.

 
I got that. So the report is bound to a table called ShortTermObsolescence. It has a field called Status.

I should be able to reference the value in the field as
me.status without having to put a control on the form.
i.e.
select case me.Status
 
Youre Amazing MajP I got it to work. I just started my table from scratch.

If I could hug you. I would.
 
Paul, I am a little uncomfortable with that. I just take the star instead and call it even.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top