Holden
Holden

Reputation: 143

Conditional picture in an access form

I would like to know whether it is possible or not to display a conditional picture in a form. Example:

if X>0 then picture 1 is displayed else picture 2 is displayed

I have looked for it but I didn't find anything

Thank you

Upvotes: 1

Views: 3344

Answers (1)

Christian Specht
Christian Specht

Reputation: 36431

If X > 0 Then
    Me.Picture = "c:\picture1.jpg"
Else
    Me.Picture = "c:\picture2.jpg"
End If

Or if the picture is not directly on the form, but in a image control:

If X > 0 Then
    Me.NameOfImageControl.Picture = "c:\picture1.jpg"
Else
    Me.NameOfImageControl.Picture = "c:\picture2.jpg"
End If

EDIT:

Okay, you can do this when you have the form open in design mode:

  • there is a button in the toolbar to open the code window:
    code window button
    (the screenshot is from Access 2003, I don't know which version you're using)

  • you can run code on events in the form like when the form is opened or closed.
    Check out this tutorial (Page 10).

And here is another tutorial about VBA Basics in Access.

Upvotes: 1

Related Questions