Solved

Multiple Function Controls

Posted on 2003-12-04
5
178 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MsgBox 2 61
VBA/SQL - Connect to SQL server and pull data 4 137
MS Date Picker 64 bit 32 bit issue 12 65
How to set the sa password in a vb6 code for sql connection 9 63
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

726 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