Conditionally displaying an image.

A

andyw

I'm trying to get an image1 to display if a value is empty and display
image2 to display if not.

I've found this line of code which seems to work:

if IsNull(forms!form1!txtbox1.Value) = True then img1.Picture =
"C:\mypic.jpg" else img1.Picture = ""

the trouble is form1 is not open at the time this code runs. I tried
numerous things to fix. A thought a subform might do the trick however
all i get is an error messge:

"Microsoft Access can't find form 'form1' referred in a macro
expression or Visual Basic Code".

I'm after suggestions as to how I could get this to work ?
 
S

Stephen Lebans

Open the form before you call your code. Open it in hidden mode if this
conforms closer to the desired UI.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
A

andyw

I've some success but refencing the sub form, not sure though if it is
the best way.

I now have a new problem, getting an error with following code (if else
error). It worked when there was just one statement:

Private Sub Form_Current()

If
IsNull(Forms!frm_main!frm_del!frm_review_status_sub.Form!review_start.Value)
= False And
IsNull(Forms!frm_main!frm_del!frm_status_sub.Form!review_finish.Value)
= False Then Image1.Picture = "C:\cross.gif"

Else: If
IsNull(Forms!frm_main!frm_delivery!frm_review_status_sub.Form!review_start.Value)
= True And
IsNull(Forms!frm_main!frm_del!frm_status_sub.Form!review_finish.Value)
= False Then Image1.Picture = "C:\arrow.gif"

Else: If
IsNull(Forms!frm_main!frm_delivery!frm_review_status_sub.Form!review_start.Value)
= True And
IsNull(Forms!frm_main!frm_del!frm_status_sub.Form!review_finish.Value)
= True Then Image1.Picture = "C:\tick.gif"

End Sub

I also need it to update if time a record selector is clicked. At the
moment its only updating once the form is opened (current event)
 

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