UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Hide Subforms, Access 2010    
 
   
mike60smart
post Sep 13 2017, 11:23 AM
Post#1


UtterAccess VIP
Posts: 12,191
Joined: 6-June 05
From: Dunbar,Scotland


Hi Everyone

I am trying to make a number of suborms hidden on the after Update of a specific Unbound Combobox named cbo2Reason.

I am using this Code but nothing happens.

Any help appreciated.

If Me.txtReason Is Not Null Then
Forms!frmLocation!frmSection3subform.Visible = False
Forms!frmLocation!frmSection4subform.Visible = False
Forms!frmLocation!frmSection5subform.Visible = False

Else
Forms!frmLocation!frmSection3subform.Visible = True
Forms!frmLocation!frmSection4subform.Visible = True
Forms!frmLocation!frmSection5subform.Visible = True

End If

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
theDBguy
post Sep 13 2017, 11:27 AM
Post#2


Access Wiki and Forums Moderator
Posts: 70,629
Joined: 19-June 07
From: SunnySandyEggo


Hi Mike,

Use IsNull() instead of Is Not Null.

Hope it helps...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
tina t
post Sep 13 2017, 12:00 PM
Post#3



Posts: 5,163
Joined: 11-November 10
From: SoCal, USA


QUOTE
If Me.txtReason Is Not Null Then
Forms!frmLocation!frmSection3subform.Visible = False
Forms!frmLocation!frmSection4subform.Visible = False
Forms!frmLocation!frmSection5subform.Visible = False

Else
Forms!frmLocation!frmSection3subform.Visible = True
Forms!frmLocation!frmSection4subform.Visible = True
Forms!frmLocation!frmSection5subform.Visible = True

End If

hi Mike, since the Visible property is a boolean value (True/False) you can make your code a bit shorter and easier with the following, as

CODE
Dim bln As Boolean

bln = IsNull(Me.txtReason)

Forms!frmLocation!frmSection3subform.Visible = bln
Forms!frmLocation!frmSection4subform.Visible = bln
Forms!frmLocation!frmSection5subform.Visible = bln

hth
tina

--------------------
"you can't take the sky from me"
Go to the top of the page
 
mike60smart
post Sep 13 2017, 12:43 PM
Post#4


UtterAccess VIP
Posts: 12,191
Joined: 6-June 05
From: Dunbar,Scotland


Hi theDbGuy & Tina

Both methods do not work ??


--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
Larry Larsen
post Sep 13 2017, 02:47 PM
Post#5


UA Editor + Utterly Certified
Posts: 24,098
Joined: 26-August 02
From: Melton Mowbray,Leicestershire (U.K)


Hi Mike

You mention two controls.. Combo & txtbox.

How are these linked..???

Combo driving txtbox..??
thumbup.gif

--------------------
"Time...We have exactly the same number of hours per day that were given to Helen Keller, Pasteur, Michaelangelo, Mother Teresa, Leonardo da Vinci, Thomas Jefferson, and Albert Einstein"
H. Jackson Brown
Go to the top of the page
 
mike60smart
post Sep 13 2017, 03:43 PM
Post#6


UtterAccess VIP
Posts: 12,191
Joined: 6-June 05
From: Dunbar,Scotland


Hi Larry

Yes txtReason is showing Column(1) from the Combobox


--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
tina t
post Sep 13 2017, 03:48 PM
Post#7



Posts: 5,163
Joined: 11-November 10
From: SoCal, USA


QUOTE
You mention two controls.. Combo & txtbox.

good catch, Larry! :)

Mike, you said

QUOTE
I am trying to make a number of suborms hidden on the after Update of a specific Unbound Combobox named cbo2Reason.

I am using this Code but nothing happens.

Any help appreciated.

If Me.txtReason Is Not Null Then

you're running the code in control cbo2Reason's AfterUpdate event, but your code is looking at the value of a control named txtReason. which control holds the value that should determine whether to show or hide the subforms?

hth
tina

--------------------
"you can't take the sky from me"
Go to the top of the page
 
mike60smart
post Sep 14 2017, 05:05 AM
Post#8


UtterAccess VIP
Posts: 12,191
Joined: 6-June 05
From: Dunbar,Scotland


Hi tina

Both the Combobox and the txtReason Controls have values but the after update does not hide the subforms


--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
tina t
post Sep 14 2017, 11:31 AM
Post#9



Posts: 5,163
Joined: 11-November 10
From: SoCal, USA


hi Mike, suggest you double check the names of the combobox and textbox controls, and also the names of the subform controls - remember that you want to change the Visible property of the subform controls, not the forms they're holding. also, is your code compiling without error? are you getting any error msg when the combo's AfterUpdate event runs? and finally, are you actually updating the combobox control - are you sure the AfterUpdate event is running?

hth
tina

--------------------
"you can't take the sky from me"
Go to the top of the page
 
mike60smart
post Sep 14 2017, 01:02 PM
Post#10


UtterAccess VIP
Posts: 12,191
Joined: 6-June 05
From: Dunbar,Scotland


Hi tina

Found the problem. All names etc were correct it was just where I had placed your code.

It now works as expected

Many thanks

kisses.gif pompom.gif

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
tina t
post Sep 14 2017, 02:49 PM
Post#11



Posts: 5,163
Joined: 11-November 10
From: SoCal, USA


great, Mike, we're all happy to help! :) tina

--------------------
"you can't take the sky from me"
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    19th September 2017 - 12:09 PM