Hide Tabs

  • Thread starter GMartin via AccessMonster.com
  • Start date
G

GMartin via AccessMonster.com

In the following code below i have a series of tabs. I want to hide all tabs
when form is opened unless field is greater than a certain # then I need for
the appropriate tabs to show. This works fine except when I scroll through
and reach a record that has staff count at 0 then i get an error. I can
cancel debug and the remaining records work and the tabs will hide and be
visible as the numbers change.

Me.Inmate_Victim_1.Visible = _
(Me.NoVictims > 0)
Me.Inmate_Victim_2.Visible = _
(Me.NoVictims > 1)
Me.Inmate_Victim_3.Visible = _
(Me.NoVictims > 2)
Me.Inmate_Victim_4.Visible = _
(Me.NoVictims > 3)
Me.Inmate_Victim_5.Visible = _
(Me.NoVictims > 4)
Me.Inmate_Victim_6.Visible = _
(Me.NoVictims > 5)
Me.Inmate_Aggressor_1.Visible = _
(Me.NoAggressors > 0 And Me.IncidentType Like
"*Inmate/Inmate*")
Me.Inmate_Aggressor_2.Visible = _
(Me.NoAggressors > 1 And Me.IncidentType Like
"*Inmate/Inmate*")
Me.Inmate_Aggressor_3.Visible = _
(Me.NoAggressors > 2 And Me.IncidentType Like
"*Inmate/Inmate*")
Me.Inmate_Aggressor_4.Visible = _
(Me.NoAggressors > 3 And Me.IncidentType Like
"*Inmate/Inmate*")
Me.Inmate_Aggressor_5.Visible = _
(Me.NoAggressors > 4 And Me.IncidentType Like
"*Inmate/Inmate*")
Me.Inmate_Aggressor_6.Visible = _
(Me.NoAggressors > 5 And Me.IncidentType Like
"*Inmate/Inmate*")
Me.Staff_Aggressor_1.Visible = _
(Me.NoAggressors > 0 And Me.IncidentType Like "Staff*")
Me.Staff_Aggressor_2.Visible = _
(Me.NoAggressors > 1 And Me.IncidentType Like "Staff*")
Me.Staff_Aggressor_3.Visible = _
(Me.NoAggressors > 2 And Me.IncidentType Like "Staff*")
Me.Staff_Aggressor_4.Visible = _
(Me.NoAggressors > 3 And Me.IncidentType Like "Staff*")
Me.Staff_Aggressor_5.Visible = _
(Me.NoAggressors > 4 And Me.IncidentType Like "Staff*")
Me.Staff_Aggressor_6.Visible = _
(Me.NoAggressors > 5 And Me.IncidentType Like "Staff*")
 
G

GMartin via AccessMonster.com

Runtime error 2165. You can't hide a control that has the focus. (this
happens when I scroll through records and get to a record that has 0 victims
and 0 staff.
What error?
In the following code below i have a series of tabs. I want to hide all tabs
when form is opened unless field is greater than a certain # then I need for
[quoted text clipped - 45 lines]
Me.Staff_Aggressor_6.Visible = _
(Me.NoAggressors > 5 And Me.IncidentType Like "Staff*")
 
J

John W. Vinson

In the following code below i have a series of tabs. I want to hide all tabs
when form is opened unless field is greater than a certain # then I need for
the appropriate tabs to show. This works fine except when I scroll through
and reach a record that has staff count at 0 then i get an error. I can
cancel debug and the remaining records work and the tabs will hide and be
visible as the numbers change.

Me.Inmate_Victim_1.Visible = _
(Me.NoVictims > 0)

You're not checking for zero - none of the branches handle that case!

I have some REAL concerns about your database structure. Fields named
Inmate_Victim_1 and Inmate_Victim_2 very strongly suggest that you are
"committing spreadsheet" on your database. If there is a one to many
relationship to victims, you should certainly *NOT* have a field for each
victim; you should instead have a one to many relationship to another table,
in which you can enter a different victim in each *RECORD*. "Fields are
expensive, records are cheap"!

John W. Vinson [MVP]
 
S

Stuart McCall

<SNIP>

"Fields are expensive, records are cheap"!

Hi John

That's a great way of putting it IMO. Well said! :)
 
J

John W. Vinson

<SNIP>

"Fields are expensive, records are cheap"!

Hi John

That's a great way of putting it IMO. Well said! :)

I really should google for who first said that - you maybe!? I stole it ages
ago and have been using it ever since.

John W. Vinson [MVP]
 

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

Similar Threads

Subform Nightmare.. 6
Subform Dilemma 2
One note creating multiple tabs when collaborating? 0
duplicates 2
Forms design 1
Not sure if this can be done in access 1
Using "tiles" 1
Need help with Tabs 2

Top