Show an image based on another field? (1 Viewer)

YNWA

Registered User.
Local time
Today, 23:43
Joined
Jun 2, 2009
Messages
905
Hi,

I need to show an image called PAID if my hidden field Paid Date has a date in.

I thought this would be straight forward but so far nothing.

I have my images within the database itself on Access 2010, so I am not referencing any in a C drive or other location.

Any ideas?

Currently trying:

Code:
Private Sub Report_Current()
On Error GoTo ErrHandler
  
    If paiddate = Date Then
        Paid.Visible = True
    Else
        Paid.Visible = False
    End If
  
ErrHandler:
    MsgBox "Error detected, error # " & Err.Number & ", " & Err.Description, vbOKOnly, "Error"
End Sub

But with no joy.

Thanks
 

pr2-eugin

Super Moderator
Local time
Today, 23:43
Joined
Nov 30, 2011
Messages
8,494
If I am reading this correctly,
I need to show an image called PAID if my hidden field Paid Date has a date in.
you have 'a date' inside, not Today's date. As Date will return today's date.. Thus explaining why it does not satisfy the condition.. You may replace the code as,
Code:
If [URL="http://www.techonthenet.com/access/functions/advanced/isdate.php"]IsDate([/URL]paiddate) Then
     Paid.Visible = True
Else
    Paid.Visible = False
End If
I have my images within the database itself on Access 2010, so I am not referencing any in a C drive or other location.
:eek: will that not result in a Bloat? For records even as little above 500?
 

YNWA

Registered User.
Local time
Today, 23:43
Joined
Jun 2, 2009
Messages
905
If I am reading this correctly, you have 'a date' inside, not Today's date. As Date will return today's date.. Thus explaining why it does not satisfy the condition.. You may replace the code as,
Code:
If [URL="http://www.techonthenet.com/access/functions/advanced/isdate.php"]IsDate([/URL]paiddate) Then
     Paid.Visible = True
Else
    Paid.Visible = False
End If
:eek: will that not result in a Bloat? For records even as little above 500?

The image is across the board.

Its for a Invoice. So if its paid the watermark of Paid Thank You appear on the Report to print out. If its not paid then the image wont show.

Wil ltry your code now and let you know. Thanks
 

YNWA

Registered User.
Local time
Today, 23:43
Joined
Jun 2, 2009
Messages
905
That seems to work, howver the watermark only disappears if I click into the report. Then I get an error detected, if I click OK on that message the image disappears.

I changed the code to Load and the clicking on report to repove image has gone but the error message always pops up. Clicking OK then opens the report and looks fine.

Any ideas on fixing this?
 

YNWA

Registered User.
Local time
Today, 23:43
Joined
Jun 2, 2009
Messages
905
I get message:

Error detected, error # 0,

Upon clicking OK, everything seems fine with the report. Images shows when it should and doesn't show when it should.

Just need to get rid off this message it seems or fix it?
 

pr2-eugin

Super Moderator
Local time
Today, 23:43
Joined
Nov 30, 2011
Messages
8,494
Okay, two things..

(a) Wrong choice of event - Current will work only when the Record has focus. Load will be called only once in the Form/Reports life time.. Might need a combination of Load and Current.. Loop through the RecordsetClone to set this image.

(b) Not a proper Error handling routine. A good document for Error handling, I always look back to is by Chip Pearson. Take a look at it..
Code:
Private Sub Report_Current()
On Error GoTo ErrHandler
  
    If IsDate(paiddate) Then
        Paid.Visible = True
    Else
        Paid.Visible = False
    End If
[B][COLOR=Red]exitErr:
    Exit Sub[/COLOR][/B]
ErrHandler:
    MsgBox "Error detected, error # " & Err.Number & ", " & Err.Description, vbOKOnly, "Error"
    [COLOR=Red][B]Resume exitErr[/B][/COLOR]
End Sub
 

YNWA

Registered User.
Local time
Today, 23:43
Joined
Jun 2, 2009
Messages
905
Changed the error routine and it works fine mate. Thank you.

Not sure on the loop thing.

When I generate orders, the invoice is created on the fly. So its not stored, the invoice is a report that is generated from a query then used to print/post.

Seems to be working sound now.
 

pr2-eugin

Super Moderator
Local time
Today, 23:43
Joined
Nov 30, 2011
Messages
8,494
Oh okay.. My bad.. I thought you have a list of all Orders or something like that.. If it is going to be only one record then that's fine..
 

YNWA

Registered User.
Local time
Today, 23:43
Joined
Jun 2, 2009
Messages
905
Oh okay.. My bad.. I thought you have a list of all Orders or something like that.. If it is going to be only one record then that's fine..

We have lists of orders, but the invoices are only generated via a query which feeds a report.
 

Users who are viewing this thread

Top Bottom