Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 24th, 2005, 04:01 PM
Authorized User
 
Join Date: Mar 2005
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to hide a combo box?

I have a tracking form with 4 combo boxes. I want my form to open with 2 of them hidden, Groups and Names, until I choose the option "Rules" in the first combo box, ChangeMade. I put the code below in the OnOpen event of the form.

me.groups.visible = false
me.names.visible = false

I have the code below in the AfterUpdate event of ChangeMade.

Private Sub ChangeMade_AfterUpdate()
   Me.ChangeType = Null
   Me.ChangeType.Requery
   Me.ChangeType = Me.ChangeType.ItemData(0)
   If Me.ChangeMade.Value = "Rules" Then
          Me.Groups.Visible = True
          Me.Names.Visible = True
 End If
 End Sub

The Requery works fine, driving the options that are available in another combo box, ChangeType. But the If-Then routine does not cause Groups and Names to appear when I choose Rules in ChangeMade. I have ChangeMade set up so all my choice options are in the first column of the table for ChangeMade. Any ideas as to why Groups and Names won't come out of hiding?

Thanks!
 
Old March 24th, 2005, 04:29 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hey Bad,

If Me.ChangeMade = "Rules" Then ...

I don't believe that you need the .value

Try it and see, let me know.

Kevin

dartcoach
 
Old March 24th, 2005, 04:35 PM
Authorized User
 
Join Date: Mar 2005
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I made the change you suggested, my combo boxes still refuse to come out of hiding. I'm either really close to getting my form designed the way I want it or very far away and too inexperienced to know....

Thanks!

Jen
 
Old March 24th, 2005, 04:46 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Jen,

The two combo boxes that you want hidden, is their visible property set to no as default?
If not, try that, then take out the code to hide them in the on open event.

I don't know. Your code looks fine. Maybe 1 other thing -

Private Sub ChangeMade_AfterUpdate()
   If Me.ChangeMade.Value = "Rules" Then
          Me.Groups.Visible = True
          Me.Names.Visible = True
   End If
   Me.ChangeType = Null
   Me.ChangeType.Requery
   Me.ChangeType = Me.ChangeType.ItemData(0)
 End Sub

Putting the If statement before the requery, but I don't know if that will make any difference at all.

Let me know.

Kevin


dartcoach
 
Old March 24th, 2005, 05:02 PM
Authorized User
 
Join Date: Mar 2005
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Did that, removed the code from the OnOpen event, added the .value back to the code, and moved the If-Then statement above the Requery. And set the Visible property of Groups and Names to No. They are still hiding! It's like after the Visible property is set to No, either manually or with code, that it doesn't change back to Yes.

The 2 columns in ChangeMade are ChangeID and Change Made To. ChangeID is an autonumber field that I use only to set up the relationships between the tables. ChangeID was the first (0) column in the table, but I got a bit of info that the code will only look at the first column. So I switched them, hoping to avoid having to add more to the code.

Jen
 
Old March 24th, 2005, 07:18 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Jen,

Put a msgbox in the after update to see just what's in changemade.

Let me know.

Kevin

dartcoach
 
Old March 24th, 2005, 10:15 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

You might also check your row source for the ChangeMade combo box.

For instance, if the Row Source Type is Table/Query, and your Row source is a query that selects two fields, the Bound Column might be an ID field. In this case you probably have Column Count set to 2 with Column Widths set to 0";2" or something.

If that's what you're doing, use ChangeMade.Column(1) to check for "Rules", or use the ID to the Rules record.

If your Row Source Type is List, then I just wasted my time explaining this.:)

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
 
Old March 25th, 2005, 09:01 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

The .value will not affect anything and I never use them.

The only "Did you remember to turn it on?" type question is this: Are you sure ChangeMade is ever equal to "Rules"? Check your dropdown and make sure it's not "RULES" or "rules" or singular instead of plural, etc.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old March 25th, 2005, 09:13 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

Of course case doesn't matter unless you're using something other than "Option Compare Database" in your code. That line is automatically added for you.

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
 
Old March 25th, 2005, 11:54 AM
Authorized User
 
Join Date: Mar 2005
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I want to thank all of you for your wonderful assistance. Randall gave me what I needed to get this to work!!!! I LOVE you!!! I had to add the Column(1) to the If-Then statement and remove the .value. Groups and Names would appear when I chose Rules, but would not dissappear. So back to what I had before, I put the code in the OnOpen event to make Groups and Names invisible when I open the form. Then I added an Else statement to the If/Then so Groups and Names will not be visible when I choose an option other than Rules. Works great!!

Thanks again!!!

Jen






Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo box to display items from parent combo box Gini Visual Studio 2008 0 June 18th, 2008 12:30 AM
Count in combo box(display results in text box) mboyisis Access 4 April 4th, 2008 07:08 AM
Combo box choice creating filtered combo box stevensj5 Access 11 September 13th, 2007 11:33 AM
How to hide combo box behind the popup menu? mohini ASP.NET 1.x and 2.0 Application Design 4 March 22nd, 2006 12:22 AM
Populate List Box by Combo Box Selection mmcdonal Access 2 June 15th, 2004 12:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.