Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-19-2019, 05:57 PM
ScottyBee ScottyBee is offline Loop through Multiple Boolean Variables Windows 10 Loop through Multiple Boolean Variables Office 2016
Novice
Loop through Multiple Boolean Variables
 
Join Date: Mar 2019
Location: Portland, Oregon
Posts: 12
ScottyBee is on a distinguished road
Default Loop through Multiple Boolean Variables

Hello,




I am getting a "type mismatch" error when looping through Boolean variables trying to identify any variables that have a value of FALSE.



My code resides in a Module and is below:
Code:
Public txt1Changed As Boolean
Public txt2Changed As Boolean
Public txt3Changed As Boolean
Public txt4Changed As Boolean
Public txt5Changed As Boolean
Public txt6Changed As Boolean
Public txt7Changed As Boolean
Public txt8Changed As Boolean
Public cbo1Changed As Boolean
Public cbo2Changed As Boolean
Public cbo3Changed As Boolean



Public Sub Test()
    txt1Changed = True
    txt2Changed = True
    txt3Changed = True
    txt4Changed = True
    txt5Changed = True
    txt6Changed = True
    txt7Changed = False
    txt8Changed = True
    Dim i As Integer
      For i = 1 To 8
            If ("txt" & CStr(i) & "Changed") = False Then
                MsgBox ("Textbox " & i & " has not been changed.")
                '.SetFocus
                Exit Sub
            End If
      Next i
End Sub
Once I get this to work, I will be applying this to a VBA form that validates that all fields on a form have been changed before allowing the user to submit the data.


Thanks for any help

Last edited by Charles Kenyon; 03-26-2019 at 06:51 AM. Reason: Mark as solved
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Generate template-based letter with multiple variables shallaes Word VBA 5 07-12-2018 12:18 AM
Multiple Problems with a loop Radtastic10 Excel Programming 3 06-09-2017 09:38 AM
Testing multiple values of two independant variables and charting results sgcannon Excel 0 10-20-2015 10:10 AM
Array to iterate through variables and trap blank variables Marrick13 Word VBA 5 08-04-2015 06:19 AM
Same values of variables in word add-in are being shared across multiple document naq.abbas@gmail.com Word 0 01-13-2014 10:41 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:15 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft