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 December 22nd, 2003, 04:21 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default Loop thru controls

I have a form that has 20 hidden combo boxes on them and based on the event of a visible combobox I want to turn certain ones on and the rest off.

Each has the same name with a suffix of a number

I can make them visible well enough using Select Case, but I need to make them invisible right before I make the corect ones visible on subsequent times and I don't want to hard code every one. I thought that I would just put a loop at the top before the Select and turn them all in visible then let the individual Case statement make visible the one it needs. But I can't seem to get the syntax right.

I have the code:

Dim FormCounter As Integer
Dim z As String
For FormCounter = 1 To 20
  z = "lblLable_" & FormCounter
  'This, and the next lines, is what I am trying to automate with the next line--> Me.lblLable_1.Visible = False
  Forms!F_ToolingTypeSelectionForReport! & z & .Visible = False
  Me.lblLable_1.caption = ""
  Me.cbxFrom_1.Visible = False
  Me.cbxThru_1.Visible = False
Next FormCounter

How can I automate this? I am getting tripped on "Forms" line of code not being parsed correctly.


__________________
__________________
Mitch
 
Old December 22nd, 2003, 10:58 PM
sal sal is offline
Friend of Wrox
 
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Why not create a table with the values that you would like to use and then show all of them in the form and select only the ones that you would like with a SQL statement. Once they have populated the list box, just select the ones that you want via the doubleclick event, which would move them to another list box. From there you can use the values.



Sal
 
Old December 23rd, 2003, 02:14 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I got this to work:

'**Turn invisible all the combo boxes and lables, otherwise they stay visible
'when you select a different item that uses less items the what was previously displayed

Dim FormCounter As Integer

For FormCounter = 1 To 20
    Me.Controls.Item("lblLable_" & FormCounter).Visible = False
    Me.Controls.Item("cbxFrom_" & FormCounter).Visible = False
    Me.Controls.Item("cbxThru_" & FormCounter).Visible = False
Next FormCounter

'************************************************* ************





Similar Threads
Thread Thread Starter Forum Replies Last Post
User controls' content: Chapter 2 User Controls AGS BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 10 July 26th, 2007 05:36 AM
loop through controls and master page fraperz ASP.NET 2.0 Professional 2 June 19th, 2007 01:25 PM
Using Controls within a For...Next loop FalseParadigm Access VBA 3 December 20th, 2006 10:01 AM
For...Next Loop msmagied Classic ASP Components 1 August 2nd, 2004 06:01 PM
nested while loop doesn't loop hosefo81 PHP Databases 5 November 12th, 2003 08:46 AM





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