Problem with hiding controls

A

Alain

Hi,

I am having some problem hiding/unhiding some control based on a checkbox
value.
For some reason nothing seems to work at all, here is the code I use
If Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible = True
Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= True
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible =
True
Forms![frmownedproperties]![subformcompany]![Line482].Visible = True
ElseIf Not Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible = False
Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= False
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible =
False
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
False
End If

My controls are set up originally at visible= No
Can anybody help me out on this one

Thanks
 
M

Marshall Barton

Alain said:
I am having some problem hiding/unhiding some control based on a checkbox
value.
For some reason nothing seems to work at all, here is the code I use
If Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible = True
Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= True
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible =
True
Forms![frmownedproperties]![subformcompany]![Line482].Visible = True
ElseIf Not Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible = False
Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= False
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible =
False
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
False
End If


Where is that code? As just a guess, it would be in both
the Form's Current event and in the check box's AfterUpdate
event procedures.

BTW, that code could be much more concise:

With Forms![frmownedproperties]![subformcompany].FORM
![Tenant].Visible = Lease3rdParty
![TenantContact].Visible = Lease3rdParty
![TenantNotes].Visible = Lease3rdParty
![Line482].Visible = Lease3rdParty
End With
 
A

Alain

It is in both control, form current and the check box

Marshall Barton said:
Alain said:
I am having some problem hiding/unhiding some control based on a checkbox
value.
For some reason nothing seems to work at all, here is the code I use
If Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
True

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= True
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
True
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
True
ElseIf Not Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
False

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= False
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
False
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
False
End If


Where is that code? As just a guess, it would be in both
the Form's Current event and in the check box's AfterUpdate
event procedures.

BTW, that code could be much more concise:

With Forms![frmownedproperties]![subformcompany].FORM
![Tenant].Visible = Lease3rdParty
![TenantContact].Visible = Lease3rdParty
![TenantNotes].Visible = Lease3rdParty
![Line482].Visible = Lease3rdParty
End With
 
A

Alain

Marsh,
I need to understand something, why do the code need to be in the
AfterUpdate, shouldn't it be in the OnClick event ??
If you click on the check box then the event is hapenning, right??

Thanks for the teaching

Alain


Marshall Barton said:
Alain said:
I am having some problem hiding/unhiding some control based on a checkbox
value.
For some reason nothing seems to work at all, here is the code I use
If Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
True

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= True
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
True
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
True
ElseIf Not Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
False

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= False
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
False
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
False
End If


Where is that code? As just a guess, it would be in both
the Form's Current event and in the check box's AfterUpdate
event procedures.

BTW, that code could be much more concise:

With Forms![frmownedproperties]![subformcompany].FORM
![Tenant].Visible = Lease3rdParty
![TenantContact].Visible = Lease3rdParty
![TenantNotes].Visible = Lease3rdParty
![Line482].Visible = Lease3rdParty
End With
 
A

Alain

March,

sorry but after trying it in the AfterUpdate event, still nothing hapenning,
my controls are still hiden.
Tried also your code before I modify mine and still no success




Marshall Barton said:
Alain said:
I am having some problem hiding/unhiding some control based on a checkbox
value.
For some reason nothing seems to work at all, here is the code I use
If Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
True

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= True
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
True
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
True
ElseIf Not Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
False

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= False
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
False
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
False
End If


Where is that code? As just a guess, it would be in both
the Form's Current event and in the check box's AfterUpdate
event procedures.

BTW, that code could be much more concise:

With Forms![frmownedproperties]![subformcompany].FORM
![Tenant].Visible = Lease3rdParty
![TenantContact].Visible = Lease3rdParty
![TenantNotes].Visible = Lease3rdParty
![Line482].Visible = Lease3rdParty
End With
 
M

Marshall Barton

For a check box, I think it won't matter whether you use the
Clcik or AfterUpdate event. For some other controls (e.g.
text box), you do not use a click to change the value, so,
for the sake of consistency, I prefer to use the AfterUpdate
everywhere.
--
Marsh
MVP [MS Access]

I need to understand something, why do the code need to be in the
AfterUpdate, shouldn't it be in the OnClick event ??
If you click on the check box then the event is hapenning, right??


Alain said:
I am having some problem hiding/unhiding some control based on a checkbox
value.
For some reason nothing seems to work at all, here is the code I use
If Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
True

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= True
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
True
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
True
ElseIf Not Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
False

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= False
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
False
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
False
End If


Where is that code? As just a guess, it would be in both
the Form's Current event and in the check box's AfterUpdate
event procedures.

BTW, that code could be much more concise:

With Forms![frmownedproperties]![subformcompany].FORM
![Tenant].Visible = Lease3rdParty
![TenantContact].Visible = Lease3rdParty
![TenantNotes].Visible = Lease3rdParty
![Line482].Visible = Lease3rdParty
End With
 
M

Marshall Barton

Are you sure the event procedure is actually running?

Double check to make sure the form's OnCurrent and the check
box's AfterUpdate properties are set to [Event Procedure].
Then click on the [...] button in the property's right
margin to jump to the procedure so you can verify that the
event property is connected to the event procedure.
--
Marsh
MVP [MS Access]

sorry but after trying it in the AfterUpdate event, still nothing hapenning,
my controls are still hiden.
Tried also your code before I modify mine and still no success


Alain said:
I am having some problem hiding/unhiding some control based on a checkbox
value.
For some reason nothing seems to work at all, here is the code I use
If Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
True

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= True
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
True
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
True
ElseIf Not Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
False

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= False
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
False
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
False
End If


Where is that code? As just a guess, it would be in both
the Form's Current event and in the check box's AfterUpdate
event procedures.

BTW, that code could be much more concise:

With Forms![frmownedproperties]![subformcompany].FORM
![Tenant].Visible = Lease3rdParty
![TenantContact].Visible = Lease3rdParty
![TenantNotes].Visible = Lease3rdParty
![Line482].Visible = Lease3rdParty
End With
 
A

Alain

Marsh,

both controls (check box and form) are set at the proper event procedure,
OnClick and AfterUpdate (for testing here) for the checkbox and OnCurrent
for the form.

Alain


Marshall Barton said:
Are you sure the event procedure is actually running?

Double check to make sure the form's OnCurrent and the check
box's AfterUpdate properties are set to [Event Procedure].
Then click on the [...] button in the property's right
margin to jump to the procedure so you can verify that the
event property is connected to the event procedure.
--
Marsh
MVP [MS Access]

sorry but after trying it in the AfterUpdate event, still nothing
hapenning,
my controls are still hiden.
Tried also your code before I modify mine and still no success


Alain wrote:
I am having some problem hiding/unhiding some control based on a
checkbox
value.
For some reason nothing seems to work at all, here is the code I use
If Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
True

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= True

Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
True
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
True
ElseIf Not Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
False

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= False

Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
False
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
False
End If


Where is that code? As just a guess, it would be in both
the Form's Current event and in the check box's AfterUpdate
event procedures.

BTW, that code could be much more concise:

With Forms![frmownedproperties]![subformcompany].FORM
![Tenant].Visible = Lease3rdParty
![TenantContact].Visible = Lease3rdParty
![TenantNotes].Visible = Lease3rdParty
![Line482].Visible = Lease3rdParty
End With
 
M

Marshall Barton

I'm stumped. If the event procedure is properly connected
to the event property, I can't think of anything that you
could do wrong that wouldn't generate some kind of error.

I think you'll have place a break point in the procedure and
inspect each value to make sure the code is actually
executing and that the value of Lease3rdParty is what it's
supposed to be.
--
Marsh
MVP [MS Access]

both controls (check box and form) are set at the proper event procedure,
OnClick and AfterUpdate (for testing here) for the checkbox and OnCurrent
for the form.


Are you sure the event procedure is actually running?

Double check to make sure the form's OnCurrent and the check
box's AfterUpdate properties are set to [Event Procedure].
Then click on the [...] button in the property's right
margin to jump to the procedure so you can verify that the
event property is connected to the event procedure.

sorry but after trying it in the AfterUpdate event, still nothing
hapenning,
my controls are still hiden.
Tried also your code before I modify mine and still no success


Alain wrote:
I am having some problem hiding/unhiding some control based on a
checkbox
value.
For some reason nothing seems to work at all, here is the code I use
If Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
True

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= True

Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
True
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
True
ElseIf Not Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
False

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= False

Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
False
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
False
End If


Where is that code? As just a guess, it would be in both
the Form's Current event and in the check box's AfterUpdate
event procedures.

BTW, that code could be much more concise:

With Forms![frmownedproperties]![subformcompany].FORM
![Tenant].Visible = Lease3rdParty
![TenantContact].Visible = Lease3rdParty
![TenantNotes].Visible = Lease3rdParty
![Line482].Visible = Lease3rdParty
End With
 
A

Alain

I already tried using the break point and quess what, the code does not stop
at all, it seem to ignore everything.
I will transfer everything to a new db and see what come up

Thanks

Alain


Marshall Barton said:
I'm stumped. If the event procedure is properly connected
to the event property, I can't think of anything that you
could do wrong that wouldn't generate some kind of error.

I think you'll have place a break point in the procedure and
inspect each value to make sure the code is actually
executing and that the value of Lease3rdParty is what it's
supposed to be.
--
Marsh
MVP [MS Access]

both controls (check box and form) are set at the proper event procedure,
OnClick and AfterUpdate (for testing here) for the checkbox and OnCurrent
for the form.


Are you sure the event procedure is actually running?

Double check to make sure the form's OnCurrent and the check
box's AfterUpdate properties are set to [Event Procedure].
Then click on the [...] button in the property's right
margin to jump to the procedure so you can verify that the
event property is connected to the event procedure.


Alain wrote:
sorry but after trying it in the AfterUpdate event, still nothing
hapenning,
my controls are still hiden.
Tried also your code before I modify mine and still no success


Alain wrote:
I am having some problem hiding/unhiding some control based on a
checkbox
value.
For some reason nothing seems to work at all, here is the code I use
If Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
True

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= True

Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
True
Forms![frmownedproperties]![subformcompany]![Line482].Visible
=
True
ElseIf Not Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
False

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= False

Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
False
Forms![frmownedproperties]![subformcompany]![Line482].Visible
=
False
End If


Where is that code? As just a guess, it would be in both
the Form's Current event and in the check box's AfterUpdate
event procedures.

BTW, that code could be much more concise:

With Forms![frmownedproperties]![subformcompany].FORM
![Tenant].Visible = Lease3rdParty
![TenantContact].Visible = Lease3rdParty
![TenantNotes].Visible = Lease3rdParty
![Line482].Visible = Lease3rdParty
End With
 
M

Marshall Barton

If it doesn't stop at a break point, either the procedure is
not being called or, far less likely, the module is
corrupted.
--
Marsh
MVP [MS Access]

I already tried using the break point and quess what, the code does not stop
at all, it seem to ignore everything.
I will transfer everything to a new db and see what come up


to the event property, I can't think of anything that you
could do wrong that wouldn't generate some kind of error.

I think you'll have place a break point in the procedure and
inspect each value to make sure the code is actually
executing and that the value of Lease3rdParty is what it's
supposed to be.

both controls (check box and form) are set at the proper event procedure,
OnClick and AfterUpdate (for testing here) for the checkbox and OnCurrent
for the form.


Are you sure the event procedure is actually running?

Double check to make sure the form's OnCurrent and the check
box's AfterUpdate properties are set to [Event Procedure].
Then click on the [...] button in the property's right
margin to jump to the procedure so you can verify that the
event property is connected to the event procedure.


Alain wrote:
sorry but after trying it in the AfterUpdate event, still nothing
hapenning,
my controls are still hiden.
Tried also your code before I modify mine and still no success


Alain wrote:
I am having some problem hiding/unhiding some control based on a
checkbox
value.
For some reason nothing seems to work at all, here is the code I use
If Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
True

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= True

Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
True
Forms![frmownedproperties]![subformcompany]![Line482].Visible
=
True
ElseIf Not Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
False

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= False

Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
False
Forms![frmownedproperties]![subformcompany]![Line482].Visible
=
False
End If


Where is that code? As just a guess, it would be in both
the Form's Current event and in the check box's AfterUpdate
event procedures.

BTW, that code could be much more concise:

With Forms![frmownedproperties]![subformcompany].FORM
![Tenant].Visible = Lease3rdParty
![TenantContact].Visible = Lease3rdParty
![TenantNotes].Visible = Lease3rdParty
![Line482].Visible = Lease3rdParty
End With
 
J

Jeff O via AccessMonster.com

Alain, try calling the control differently. This syntax work for me.

Forms("form1").Controls("option0").Visible = True

/Jeff


Hi,

I am having some problem hiding/unhiding some control based on a checkbox
value.
For some reason nothing seems to work at all, here is the code I use
If Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible = True
Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= True
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible =
True
Forms![frmownedproperties]![subformcompany]![Line482].Visible = True
ElseIf Not Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible = False
Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= False
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible =
False
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
False
End If

My controls are set up originally at visible= No
Can anybody help me out on this one

Thanks
 
A

Alain

Hi Marsh,
After reloading everything into a new db, I still not able to apply any
breakpoint anywhere at all, not even in my modules.
Do you know what can cause this can of situation??
I am worring because this project is not quite finish and I will need to
develop more procedures and it will be very difficult to debug.

Any clues or suggestion wil lbe much helpfull

TIA

Alain


Marshall Barton said:
If it doesn't stop at a break point, either the procedure is
not being called or, far less likely, the module is
corrupted.
--
Marsh
MVP [MS Access]

I already tried using the break point and quess what, the code does not
stop
at all, it seem to ignore everything.
I will transfer everything to a new db and see what come up


to the event property, I can't think of anything that you
could do wrong that wouldn't generate some kind of error.

I think you'll have place a break point in the procedure and
inspect each value to make sure the code is actually
executing and that the value of Lease3rdParty is what it's
supposed to be.


Alain wrote:
both controls (check box and form) are set at the proper event
procedure,
OnClick and AfterUpdate (for testing here) for the checkbox and
OnCurrent
for the form.


Are you sure the event procedure is actually running?

Double check to make sure the form's OnCurrent and the check
box's AfterUpdate properties are set to [Event Procedure].
Then click on the [...] button in the property's right
margin to jump to the procedure so you can verify that the
event property is connected to the event procedure.


Alain wrote:
sorry but after trying it in the AfterUpdate event, still nothing
hapenning,
my controls are still hiden.
Tried also your code before I modify mine and still no success


Alain wrote:
I am having some problem hiding/unhiding some control based on a
checkbox
value.
For some reason nothing seems to work at all, here is the code I use
If Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible
=
True

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= True

Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
True

Forms![frmownedproperties]![subformcompany]![Line482].Visible
=
True
ElseIf Not Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible
=
False

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= False

Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
False

Forms![frmownedproperties]![subformcompany]![Line482].Visible
=
False
End If


Where is that code? As just a guess, it would be in both
the Form's Current event and in the check box's AfterUpdate
event procedures.

BTW, that code could be much more concise:

With Forms![frmownedproperties]![subformcompany].FORM
![Tenant].Visible = Lease3rdParty
![TenantContact].Visible = Lease3rdParty
![TenantNotes].Visible = Lease3rdParty
![Line482].Visible = Lease3rdParty
End With
 
A

Alain

Thanks Jeff but I need to hide a complete subform, not just a control

Alain

Jeff O via AccessMonster.com said:
Alain, try calling the control differently. This syntax work for me.

Forms("form1").Controls("option0").Visible = True

/Jeff


Hi,

I am having some problem hiding/unhiding some control based on a checkbox
value.
For some reason nothing seems to work at all, here is the code I use
If Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
True

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= True
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
True
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
True
ElseIf Not Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
False

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= False
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
False
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
False
End If

My controls are set up originally at visible= No
Can anybody help me out on this one

Thanks
 
M

Marshall Barton

Alain said:
After reloading everything into a new db, I still not able to apply any
breakpoint anywhere at all, not even in my modules.
Do you know what can cause this can of situation??
I am worring because this project is not quite finish and I will need to
develop more procedures and it will be very difficult to debug.


Ohhh boy. Now it definitely sounds like a (code?)
corruption issue.

FIRST, make a copy of the fe mdb file and only use the copy
for further activities.

I suggest that you first try decompiling the mdb to flush
out all compiled code. See:
http://www.granite.ab.ca/access/decompile.htm

For a broad discussion of corruption issues, see:
http://www.granite.ab.ca/access/corruptmdbs.htm
 
M

Matt K.

Don't know if this will get read or not but,
After reading through this thread (looking for a solution to a similar
problem I was having) I noticed something about the first line of code in
Alain's procedure...
If Lease3rdParty Then

I am new to VBcode, but doesn't there need to be a qualifier in here??? If
Lease3rdParty is a check box control, wouldn't we need something like
If Lease3rdParty=yes Then....?
Like I said, I am learning here so I hope this doesn't sound to off the wall
to the experts.


Alain said:
Thanks Jeff but I need to hide a complete subform, not just a control

Alain

Jeff O via AccessMonster.com said:
Alain, try calling the control differently. This syntax work for me.

Forms("form1").Controls("option0").Visible = True

/Jeff


Hi,

I am having some problem hiding/unhiding some control based on a checkbox
value.
For some reason nothing seems to work at all, here is the code I use
If Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
True

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= True
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
True
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
True
ElseIf Not Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
False

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= False
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
False
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
False
End If

My controls are set up originally at visible= No
Can anybody help me out on this one

Thanks
 
M

Marshall Barton

No, not if the check box is bound to a Yes/No field.
Tachnically, a Yes/No field can only be True or False so
there is no need to compare it to True to see if it's True.
OTOH, there used to be a serious bug where Access got
confused and refused to close if you did not do something to
indicate that you were referencing the Value and not the
check box object, but you should not have to worry about
that any more.

Note that Yes is not a predefined constant is Access VBA,
you would use True instead.
 
R

Rob Oldfield

....and just to add something onto Marshall's comment, there's another
similar thing that can be done with expressions that evaluate to either true
or false. The code:

me.ctlWhatever.visible=(x=2)

is a quick way of writing

if x=2 then
me.ctlWhatever.visible=true
else
me.ctlWhatever.visible=false
endif


Matt K. said:
Don't know if this will get read or not but,
After reading through this thread (looking for a solution to a similar
problem I was having) I noticed something about the first line of code in
Alain's procedure...
If Lease3rdParty Then

I am new to VBcode, but doesn't there need to be a qualifier in here??? If
Lease3rdParty is a check box control, wouldn't we need something like
If Lease3rdParty=yes Then....?
Like I said, I am learning here so I hope this doesn't sound to off the wall
to the experts.


Alain said:
Thanks Jeff but I need to hide a complete subform, not just a control

Alain

Jeff O via AccessMonster.com said:
Alain, try calling the control differently. This syntax work for me.

Forms("form1").Controls("option0").Visible = True

/Jeff



Alain wrote:
Hi,

I am having some problem hiding/unhiding some control based on a checkbox
value.
For some reason nothing seems to work at all, here is the code I use
If Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
True

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= True
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
True
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
True
ElseIf Not Lease3rdParty Then
Forms![frmownedproperties]![subformcompany]![Tenant].Visible =
False

Forms![frmownedproperties]![subformcompany]![TenantContact].Visible
= False
Forms![frmownedproperties]![subformcompany]![TenantNotes].Visible
=
False
Forms![frmownedproperties]![subformcompany]![Line482].Visible =
False
End If

My controls are set up originally at visible= No
Can anybody help me out on this one

Thanks
 

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