Image Visability defined in Expression Builder

ian_w

Registered User.
Local time
Today, 23:01
Joined
Jun 13, 2006
Messages
64
Im trying to write an expression in expression builder that sets the visibility of an image depending on a true/false value in a table.

Im getting no where with it and I can't find any relevent guides :(

Can anyone shed any light on how I would do this?
 
what part are you getting stuck on??

All of it lol

I've tried writing an If Then statement like..

If [Field] = True Then
Me.Image.Visible = True
Else
Me.Image.Visible = False
End If

I get the following error..

"The expression you entered contains an Invalid Syntax"

"You may have entered an operand without an operator"
 
Well where are you getting the Field from?? You need to tell access what table it is comming from using the data from a form or from a recordset you open in the Code.

The If then else looks fine other than the Field thing...

AND ...

Use [ code ] and [/ Code ] without the spaces when you post code... It keeps the indenting.
 
Hi,

This is what I have in the Expression Builder box..

Code:
=IIf([Data_Dir]=True,[DataImage].[Visible],[DataImage]=True.[Visible]=False)

This is written in the IIf(exp,truepart,falsepart) format of the expression builder.

Data_Dir is a Yes/No field in the table that is linked to the form and I have selected the filed from the expression builder.

DataImage is the name of the image I want to show.

Default Visible property for the Image is Visible = False.

I still cannot get my image to show though :(
 
Code:
=IIf([Data_Dir]=True,[DataImage].[Visible],[B][DataImage]=True.[/B][Visible]=False)
Check out the bolded part... that is not right, more so

You can/should not do this using an IIF??? IIF is used in queries not coding.... IF is used in "proper" coding which would make it like so.
Code:
If me.[Data_Dir] then
 me.[DataImage].[Visible] = true
else 
 Me.[DataImage].[Visible]=False
endif
[B]Me.Repaint[/B]
No I added the Repaint to the code to repaint the screen and actually show the un-hidden image.

Should work.
 
Thanks for the code namilam, I tried it but it doesn't seem to want to work, I till get syntax errors.

I think I need to approach this from a different angle now anyway, i've had another look at what im trying to do this morning and im not sure how its possible.

A bit more background on what I am after...

I have a form that shows multiple records, for each record there are a number of hidden txtbox's that become visible dependent on values in the table. The expressions for these txtbox's are written as

Code:
=IIf([Data_Dir],"There is Data","There is No Data")

That does exactly what I want, if there is a entry in the table for "Data_Dir" then it displays "There is Data" if not then I get " There is No Data".

I have tried recreating this with an image but it doesn't seem possible as its wanting me to put it to an event i.e OnClick do this... where as I need to it display individually for each record that is being shown without the need for a click or a mouse over etc.

I wrote a sub in VB but this sets the image up for a single record which is then propergated to all the other records on display which isn't what im after :(

What would be the best way to acheive what I am wanting to do?
 
In a table like view (like you have currently) all objects/images are set for ALL rows, not just the current.

I dont know a way around this, sorry :(
 

Users who are viewing this thread

Back
Top Bottom