We recently installed AttachmateReflection for UNIX and OpenVMS Objects on our hospital computers. I have written a vba macro to automate a report I use daily. The macro begins by opening up a UserForm where selections can be made for other parts of the macro, frmHILO is then Hide and the macro continues retriving variable values from frmHILO. In the past I have run the report with all the LOCATIONS in the array below. What I would like to do now is have checkboxes where I can click as few or as many checkboxes as I want to filter the report on specific locations.
From what I have read, I would need to change my static array to a dynamic arrary and ReDim. I am not very familar with arrays, I have not found a similar example to know where to start.
This is my thought process:
In this case there would be 10 new checkboxes named
Label Array elements Checkbox name
ICU 1-8 chkLoc1
5EM 9-11 chkLoc2
5WM 12-14 chkLoc3
5ES 15-17 chkLoc4
5WS 18-20 chkLoc5
7EM 21-23 chkLoc6
7WM 24-26 chkLoc7
7ES 27-29 chkLoc8
7WS 30-32 chkLoc9
9E 33-34 chkLoc10
Dim DynamicArray() As Long
For i = 1 To 10
If frmHILO.Controls("chkLoc" & i).value = True Then
Build the array from the Dynamic array
End If
Next i
ReDim DynamicArray(1 To ??) then run in the code in the ***LOCATION CODE *** section
Any help would be appreciated. Below is the static array and code.
You don't know what you don't know...
From what I have read, I would need to change my static array to a dynamic arrary and ReDim. I am not very familar with arrays, I have not found a similar example to know where to start.
This is my thought process:
In this case there would be 10 new checkboxes named
Label Array elements Checkbox name
ICU 1-8 chkLoc1
5EM 9-11 chkLoc2
5WM 12-14 chkLoc3
5ES 15-17 chkLoc4
5WS 18-20 chkLoc5
7EM 21-23 chkLoc6
7WM 24-26 chkLoc7
7ES 27-29 chkLoc8
7WS 30-32 chkLoc9
9E 33-34 chkLoc10
Dim DynamicArray() As Long
For i = 1 To 10
If frmHILO.Controls("chkLoc" & i).value = True Then
Build the array from the Dynamic array
End If
Next i
ReDim DynamicArray(1 To ??) then run in the code in the ***LOCATION CODE *** section
Any help would be appreciated. Below is the static array and code.
Code:
Dim N As Integer
Dim strLoc(1 To 34) As String
strLoc(1) = "IC/4WMICU"
strLoc(2) = "IC/4WM"
strLoc(3) = "IC/4WMPAL"
strLoc(4) = "IC/4WMOB"
strLoc(5) = "IC/4WSICU"
strLoc(6) = "IC/4WS"
strLoc(7) = "IC/4WSPAL"
strLoc(8) = "IC/4WSOB"
strLoc(9) = "IC/5EMOB"
strLoc(10) = "IC/5EM"
strLoc(11) = "IC/5EMPAL"
strLoc(12) = "IC/5WMOB"
strLoc(13) = "IC/5WM"
strLoc(14) = "IC/5WMPAL"
strLoc(15) = "IC/5ESOB"
strLoc(16) = "IC/5ESPAL"
strLoc(17) = "IC/5ES"
strLoc(18) = "IC/5WSOB"
strLoc(19) = "IC/5WS"
strLoc(20) = "IC/5WSPAL"
strLoc(21) = "IC/7EMOB"
strLoc(22) = "IC/7EM"
strLoc(23) = "IC/7EMPAL"
strLoc(24) = "IC/7WMOB"
strLoc(25) = "IC/7WM"
strLoc(26) = "IC/7WMPAL"
strLoc(27) = "IC/7ESOB"
strLoc(28) = "IC/7ES"
strLoc(29) = "IC/7ESPAL"
strLoc(30) = "IC/7WSOB"
strLoc(31) = "IC/7WS"
strLoc(32) = "IC/7WSPAL"
strLoc(33) = "IC/9WEST"
strLoc(34) = "IC/9WPOB"
Dim strLocationStrings(1 To 4) As String
strLocationStrings(1) = "Select LOCATION:"
strLocationStrings(2) = "Select another LOCATION:"
strLocationStrings(3) = "CHOOSE 1-3:"
strLocationStrings(4) = "CHOOSE 1-4:"
'******** LOCATION CODE ***************
For N = LBound(strLoc) To UBound(strLoc)
For i = 1 To 3
Select Case .Parent.Application.WaitForStrings(strLocationStrings, , rcAllowKeystrokes)
Case 1
If Len(strLoc(N)) > 6 Then
.Transmit strLoc(N) & CR
Exit For
Else: .Transmit strLoc(N) & CR
End If
Case 2
If Len(strLoc(N)) > 6 Then
.Transmit strLoc(N) & CR
Exit For
Else: .Transmit strLoc(N) & CR
End If
Case 3
.Transmit "1" & CR
Exit For
Case 4
.Transmit "1" & CR
Exit For
End Select
Next i
Next N
'******* END LOCATION CODE ************
You don't know what you don't know...