Solved

Multiple Function Controls

Posted on 2003-12-04
5
171 Views
Last Modified: 2010-05-03
I have two buttons, "Previous" and "Next".  I have multiple textbox arrays.  What I want to do is, when you click on the "Next" button the next textbox array will show, press the "Next" button again and the nex textbox after that will show, etc.

The "Previous" button needs to do the same only in reverse.  As little coding as possible would be nice.

Thanks!
0
Comment
Question by:johnqtr
  • 2
  • 2
5 Comments
 
LVL 24

Expert Comment

by:shivsa
ID: 9880159
Hi trixits,
no it not possible, the same question asked before on this many times, but answer was always no.

Cheers!
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9880168
sorry for my last comment, it was for some other post.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 9880857
It's probably more complicated than I think, but does approach the problem?

Private Sub cmdNext_Click()
    Dim i As Integer
    Dim bFlag As Boolean
    Dim bFlag2 As Boolean
    Const iBoxCount = 3
    'ensures that there is no more than one box visible
    Do Until i = iBoxCount
        If bFlag2 Then
            Text1(i).Visible = False
        Else
            If bFlag Then
               Text1(i).Visible = True
               bFlag2 = True
            Else
                If Text1(i).Visible Then
                    Text1(i).Visible = False
                    bFlag = True
                End If
            End If
        End If
        i = i + 1
    Loop
   
    'Restart at beginning
    If bFlag = False Or bFlag2 = False Then
        Text1(0).Visible = True
    End If

End Sub
0
 
LVL 2

Accepted Solution

by:
lttia1 earned 125 total points
ID: 9881082
Try this:

For this, you have to ensure that only 1 textbox is visible at runtime

Private Sub cmdNext_Click()
  Dim HighestIndex As Long
  Dim LowestIndex As Long
  Dim Index As Long
 
  HighestIndex = Text1.UBound
  LowestIndex = Text1.lBound
 
  For Index = LowestIndex To HighestIndex - 1
    If Text1(Index).Visible = True Then
      Text1(Index).Visible = False
      Text1(Index + 1).Visible = True
      Exit For
    End If
  Next
End Sub

Private Sub cmdPrevious_Click()
  Dim HighestIndex As Long
  Dim LowestIndex As Long
  Dim Index As Long
 
  HighestIndex = Text1.UBound
  LowestIndex = Text1.lBound
 
  For Index = HighestIndex To LowestIndex + 1 Step -1
    If Text1(Index).Visible = True Then
      Text1(Index).Visible = False
      Text1(Index - 1).Visible = True
      Exit For
    End If
  Next
End Sub
0
 
LVL 2

Expert Comment

by:lttia1
ID: 9881114
this means that except for textbox(0)(example), you have to set the rest of the textbox array visible property to false at design time
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now