Making Access Fields (In)Visible

Hi all

I am struggling with the control of field and label visibility in a form.

The idea is to make 2 fields and associated labels visible/invisible based on the status of a checkbox.

The checkbox is called Enl-Dome.

Following a procedure discovered on-line I am using an If statement in the AfterUpdate event of the checkbox:

= If Me.Enl-Dome=0 Then
Label64.Visible=false
Dome-Dia.visible=false
Label66.visible=false
Text65.visible=false
Else
Label64.Visible=true
Dome-Dia.visible=true
Label66.visible=true
Text65.visible=true
End If

Trying to enter this gives an error message:

The expression you entered contains invalid syntax.  You may have entered an operand without an operator.

Can anyone shed light on this newby's failings please?

Thanks

Phil

February 14th, 2015 3:25pm

Try this:

If Me.[Enl-Dome]=0 Then
 Label64.Visible=false
 [Dome-Dia].visible=false
 Label66.visible=false
 Text65.visible=false
Else
 Label64.Visible=true
 [Dome-Dia].visible=true
 Label66.visible=true
 Text65.visible=true
End If

I don't know if you added the = -sign in the IF statement but that should not be in front of the IF. Furthermore put brackets around the names that contain a dash because that might cause an issue.

Maurice

Free Windows Admin Tool Kit Click here and download it now
February 14th, 2015 4:09pm

Thanks Maurice but no change.

When I click the dotted button beside the AfterUpdate field it gave the options of Macro, Expression or Code builder.

I used the Expression option -  is this correct?

Before the leading If, an equals sign was automatically added to the expression.

As I think you've noted, I have used hyphens in some field labels, is this bad practice?

Thanks

Phil

February 14th, 2015 4:25pm

Use the code builder and you should be good to go!

Maurice

Free Windows Admin Tool Kit Click here and download it now
February 14th, 2015 6:17pm

Thanks Maurice that's got it!

Phil

February 15th, 2015 3:57am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics