Tab Control on a Form Conditionally Visible?

  • Thread starter Thread starter WildlyHarry
  • Start date Start date
W

WildlyHarry

I have a form with a number of different Tab Controls. Each tab corresponds
to a field on the main section of the form. I want the Tab Controls to only
be visible when there is data in the specific fields on the main section.

I have tried the following code with no success:

After Update Property
if me.action_item_1.value = Null then
me.tab1.visible = false
else
me.tab1.visible = true
end if
me.refresh

in conjunction with

Current Property
if me.action_item_1.value = Null then
me.tab1.visible = false
else
me.tab1.visible = true
end if
me.refresh

Does anybody have any suggestions to resolve my issue? Thanks in advance.
 
WildlyHarry said:
I have a form with a number of different Tab Controls. Each tab
corresponds
to a field on the main section of the form. I want the Tab Controls to
only
be visible when there is data in the specific fields on the main section.

I have tried the following code with no success:

After Update Property
if me.action_item_1.value = Null then
me.tab1.visible = false
else
me.tab1.visible = true
end if
me.refresh

in conjunction with

Current Property
if me.action_item_1.value = Null then
me.tab1.visible = false
else
me.tab1.visible = true
end if
me.refresh

Does anybody have any suggestions to resolve my issue? Thanks in advance.


I'm not sure whether this is your only problem or not, but you can't check
for anything being *equal to* Null. In VBA, you must use the IsNull()
function:

If IsNull(Me.action_item_1) Then
Me.tab1.Visible = False
Else
Me.tab1.Visible = True
End If

You can simplify that to this single statement:

Me.tab1.Visible = Not IsNull(Me.action_item_1)

I don't see any reason for you to be executing the "Me.Refresh" statement
that you have in your quoted code. I could be wrong, but it probably isn't
doing what you think.
 
Worked like a charm thanks

Dirk Goldgar said:
I'm not sure whether this is your only problem or not, but you can't check
for anything being *equal to* Null. In VBA, you must use the IsNull()
function:

If IsNull(Me.action_item_1) Then
Me.tab1.Visible = False
Else
Me.tab1.Visible = True
End If

You can simplify that to this single statement:

Me.tab1.Visible = Not IsNull(Me.action_item_1)

I don't see any reason for you to be executing the "Me.Refresh" statement
that you have in your quoted code. I could be wrong, but it probably isn't
doing what you think.


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)
 
Back
Top