Tab Control on a Form Conditionally Visible?

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.
 
D

Dirk Goldgar

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.
 
W

WildlyHarry

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)
 

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