ms-accessvbams-access-2003

MS ACcess Make textboxes visible upon button click


At every button click I want to be able to make "visible" 4 textboxes and 4 labels. I am not sure how to do this using VBA code.

Here is what I have tried out so far: There are no errors produced but I do not know how to proceede from here.

Private Sub Command36_Click()

Static Counter As Integer
Dim Name As String
Dim Name2 As String
Dim Count As Integer

Counter = Counter + 1

Name = "Label" & Counter
Name2 = "Text" & Counter
Command36.Caption = Name & Name2

For Count = 1 To Count = Counter

Microsoft Access Forms, VBS


Solution

  • I think you mean:

    Private Sub Command36_Click()
    Dim Name As String
    Dim Name2 As String
    Dim Count As Integer
    
    
       For Count = 1 To 4
          Name = "Label" & Counter
          Name2 = "Text" & Counter
          Command36.Caption = Name & Name2
       Next
    
    End Sub
    

    I do not quite see what is the point of the above.

    This might be of more use, if, as you say, you want to make something visible:

       For Count = 1 To 4
          Name1 = "Label" & Counter
          Name2 = "Text" & Counter
          Me(Name1).Visible = True
          Me(Name2).Visible = True
       Next
    

    Do yourself a favour and make sure you give controls "real" names, not Command36, but something like cmdShowLabel