Combo Box To Hide Tab Control

L

Lowrider72

Hi everyone...I need some help...I have been trying to get a combo box to
unhide certain tab controls when selecting certain records...this is the code
that I have tried...

If Me.cboMyComboName = 2 then
Me.MyTabControlName.Visible = True
End If

Any help would be appreciated.

Regards..
 
K

kabaka

I think your if statement is wrong (you're missing the ".value" part)

If Me.cboMyComboName.VALUE = 2 then
Me.MyTabControlName.Visible = True
End If
 
L

Lowrider72

Thanks for the help..I made the change but that still didn't work...I
inserted the code in the after_update of the combo box...Hopefuly that was
correct...I'm pulling my hair out over this one....Been looking for hours for
a solution on the net...useless!!
 
K

kabaka

Ok, then it'll be a little more complicated. First some questions:

What are the values in the combo box? Is it actually a "2" that you are
selecting or just the second row's value? You cannot just reference the
second row as that is a very unstable way to get the same value each time.
How are you populating the combo box? Value List or Table/Query?

Value list: Then you can easily just type in the value that you are
selecting as your condition. I suspect that this is not the case though.

Table/Query: Post the Sql string that is used and *exactly* the value that
you want as your condition.
 
L

Lowrider72

OK..thanks for the help...The values in the combo box are "missing",
"suspect", "witness", and "victim"...I used 2 in the code to select the
second choice in the combo box which was "missing".

Secondly, the unbound combo box is populated by a table (row source)...

Hope this helps
 
K

kabaka

Is the second choice "suspect"?

If so, and it is always the one you want to use as your condition, then your
code is simply

If Me.cboMyComboName.VALUE = "suspect" then
Me.MyTabControlName.Visible = True
End If

However, if you always want to use the second row as your choice, then we've
got a lot of work ahead of us. But I doubt this is the case.

As I said earlier, you cannot just reference the second row like this. Even
if you could it would be a bad idea. Rows within a table are not stored in
any particular order. What would happen if the order came back differently
next time?

Let me know if that works.
 
L

Lowrider72

Okay..we have some issues here lol

Firstly, yes "suspect" is what I want to use as my condition...I want to
generate codes for the other conditions...Anyway, I have entered the
following code in the after_update event of my combobox...

If Me.cboMyComboName.VALUE = "suspect" then
Me.MyTabControlName.Visible = True
End If

I have also set the visible property on the tab control to "no". I am also
using access 97 if that makes a difference....

And No, the code didn't work...Any more ideas?? lol
 
K

kabaka

See the comments inserted throughout.

Lowrider72 said:
Okay..we have some issues here lol

Yes, we do.
If Me.cboMyComboName.VALUE = "suspect" then
Me.MyTabControlName.Visible = True
End If

Are we talking about hiding an entire tab control, or just one of it's
pages? Make sure you are referencing the right place.
I have also set the visible property on the tab control to "no".

When you first open the form up, before doing anything, is the particular
tab page invisible?
I am also using access 97 if that makes a difference....

No it doesn't. That's what I'm using.
And No, the code didn't work

Try putting a break point in at the first line. Make sure that you're even
getting into the code.
...Any more ideas?? lol

Running out of them. I should point out that before responding the first
time, I made sure that I could do this. I have been able to hide/unhide a
tab page no problem, so it can be done - and more importantly - I can do it
(believe it or not!)
 
L

Lowrider72

Oh, I believe you know how to do it...that's not even the issue...

I'm just trying to hide a page on the tab control. I have designed a simple
form for testing purposes. The form is unbound. The tab control is tabctl1
and the page im tring to unhide is called "tester". The code is as follows

If Me.cbocombobox = "Suspect" then
Me.tester.Visible = True
End If

Remember I have "tester" visible properties set to no, so when the form
loads its not visible.

I tried inserting a break after the first line nd it gives me an error
message so I know its reading the code.

As a side note, i have inserted a check box to see if I could get it to
work...The check box works perfectly... The propblem is that I need the combo
works to work..lol Just for your reference the code on the check box is..

If Me.check4 = False Then
Me.tester.Visible = False
ElseIf Me.check4 = True
Me.tester.Visible = True
End If

Anyway...that was for your reference...I know a little of what im doing lol
 
K

kabaka

Post all the code for the entire AfterUpdate() event where you are getting
your error. If all that you are missing is an "End if" to get this working,
I'll know that I've been at the office too long today and it's time to go
home.
 
L

Lowrider72

I wish it was that simple...here is the entire code..

Private_Sub cboComboBox_AfterUpdate()
If Me.cboComboBox.Value = "Suspect" Then
Me.tester.Visible = True
End If
End Sub
 
L

Lowrider72

Opps, the one with the error is as follows...

Private_Sub cboComboBox_AfterUpdate()
If Me.cboComboBox.Value = "Suspect" Then _
Me.tester.Visible = True
End If
End Sub
 
K

kabaka

ok - I won't be able to look at if for about 1 1/2 hours though. Sorry.

Note: It's not a good idea to post email addresses in a newsgroup as
spammers harvest them from here (or so I've heard). You should be able for
figure out my email address though.

cpalmer at shaw dot ca
 
K

kabaka

ARRGHHHH!!

Loose the "_" after the Then and you'll be good to go. That's throwing off
your if.
 
L

Lowrider72

okay..I was under the impression everyone had a garbage hotmail account for
instances such as this lol...Hotmail is good for that..I'll send it to you
and whenever you get the chance have a look...Its the one that i have created
as a test...I've been banging my head off my desk for a few hours over this
one...I really appreciate your time and effort..

Regards
 
L

Lowrider72

Ya I know...but you suggested inserting a break so I did and I got that error
message
 
K

kabaka

Say that again... what did you do when you inserted a break? What I meant
was click on the left of the module (in the rectangle that runs beside the
code - it's offcoloured - if you did it right your line will be highlighted
and a big red dot will be beside the line) not insert a "_". That isn't a
break point.
 

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