YoungsterJerry
YoungsterJerry

Reputation: 5

Cycling through textboxes on form in MS Access

I'm trying to index through multiple textboxes in a form to change the Visible Property through an after Update event. The event occurs after a combo box designates a number of textboxes to cycle through. All the textboxes are named "V1, V2, V3...V110, etc.) I'm relatively new to VBA and Access, how would I go about coding this?

Upvotes: 0

Views: 133

Answers (1)

user3598756
user3598756

Reputation: 29421

you can use the following sub

    Option Explicit

    Sub ChangeTextBoxVisibility(iMin As Long, iMax As Long, visibilityState As Boolean)
        Dim i As Long
        With Me
            For i = iMin To iMax
                .Controls("V" & i).Visible = visibilityState
            Next i
        End With
    End Sub

to be called as

ChangeTextBoxVisibility 3, 90, False'<--| set not visible all textboxes from "V3" to "V90"

Upvotes: 3

Related Questions