-
Notifications
You must be signed in to change notification settings - Fork 3
/
Interface.frm
1049 lines (940 loc) · 37.1 KB
/
Interface.frm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
VERSION 5.00
Begin VB.Form InterfaceWindow
BorderStyle = 1 'Fixed Single
ClientHeight = 8175
ClientLeft = 45
ClientTop = 615
ClientWidth = 9270
Icon = "Interface.frx":0000
KeyPreview = -1 'True
MaxButton = 0 'False
ScaleHeight = 545
ScaleMode = 3 'Pixel
ScaleWidth = 618
StartUpPosition = 2 'CenterScreen
Begin VB.TextBox StatusBox
BackColor = &H8000000F&
BeginProperty Font
Name = "Fixedsys"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 528
Left = 120
Locked = -1 'True
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 21
TabStop = 0 'False
Top = 7530
Width = 9015
End
Begin VB.Frame ExportFrame
Caption = "Export"
ClipControls = 0 'False
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2775
Left = 4440
TabIndex = 19
Top = 120
Width = 4695
Begin VB.CommandButton ExportResultButton
Caption = "Export &Result"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2400
TabIndex = 11
Top = 2160
Width = 2055
End
Begin VB.CheckBox OpenResultAfterExportBox
Caption = "&Open result after export."
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 195
Left = 120
TabIndex = 9
Top = 1200
Width = 4452
End
Begin VB.TextBox ExportPathBox
Height = 285
Left = 120
TabIndex = 6
Top = 600
Width = 3975
End
Begin VB.CommandButton SelectExportPathButton
Appearance = 0 'Flat
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4200
Picture = "Interface.frx":030A
Style = 1 'Graphical
TabIndex = 7
Top = 600
Width = 375
End
Begin VB.CheckBox CreateEMailWithExportAttachedBox
Caption = "Create e-&mail with export attached."
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 195
Left = 120
TabIndex = 10
Top = 1440
Width = 4452
End
Begin VB.CheckBox AutomaticallyExportResultBox
Caption = "&Automatically export result after query."
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 195
Left = 120
TabIndex = 8
Top = 960
Width = 4452
End
Begin VB.Label ExportResultToLabel
Caption = "Export result to:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 252
Left = 120
TabIndex = 20
Top = 360
Width = 3972
End
End
Begin VB.Frame QueryFrame
Caption = "Query"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2775
Left = 120
TabIndex = 14
Top = 120
Width = 4215
Begin VB.CommandButton ExecuteQueryButton
Caption = "&Execute Query"
Default = -1 'True
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2400
TabIndex = 5
Top = 2160
Width = 1575
End
Begin VB.TextBox QueryPathBox
Height = 285
Left = 840
OLEDropMode = 1 'Manual
TabIndex = 0
Top = 360
Width = 2415
End
Begin VB.CommandButton SelectQueryButton
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3360
Picture = "Interface.frx":064C
Style = 1 'Graphical
TabIndex = 1
Top = 360
Width = 375
End
Begin VB.CommandButton OpenQueryButton
Appearance = 0 'Flat
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3720
Picture = "Interface.frx":098E
Style = 1 'Graphical
TabIndex = 2
Top = 360
Width = 375
End
Begin VB.Frame ParametersFrame
Caption = "Parameters"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1335
Left = 120
TabIndex = 15
Top = 720
Width = 3975
Begin VB.VScrollBar ParameterFrameScrollBar
Height = 1215
Left = 3720
Max = 0
TabIndex = 4
Top = 120
Width = 255
End
Begin VB.PictureBox ParameterBoxContainer
BorderStyle = 0 'None
Height = 975
Left = 120
ScaleHeight = 65
ScaleMode = 3 'Pixel
ScaleWidth = 241
TabIndex = 16
TabStop = 0 'False
Top = 240
Width = 3615
Begin VB.TextBox ParameterBoxes
Height = 285
Index = 0
Left = 1440
Locked = -1 'True
TabIndex = 3
Top = 0
Width = 2055
End
Begin VB.Label ParameterLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "Parameter:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 192
Index = 0
Left = 48
TabIndex = 18
Top = 0
Width = 1176
End
End
End
Begin VB.Label QueryLabel
Alignment = 1 'Right Justify
Caption = "Query:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 120
TabIndex = 17
Top = 360
Width = 615
End
End
Begin VB.Frame ResultFrame
Caption = "Result"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 4455
Left = 120
TabIndex = 13
Top = 3000
Width = 9015
Begin VB.TextBox QueryResultBox
BeginProperty Font
Name = "Fixedsys"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 4095
Left = 120
Locked = -1 'True
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 12
Top = 240
Width = 8775
End
End
Begin VB.Menu ProgramMainMenu
Caption = "&Program"
Begin VB.Menu InformationMenu
Caption = "&Information"
Shortcut = ^I
End
Begin VB.Menu CloseMenu
Caption = "&Close"
Shortcut = ^Q
End
End
End
Attribute VB_Name = "InterfaceWindow"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'This module contains this program's interface window.
Option Explicit
'This procedure adjusts the scrollbar so that the specified parameter box becomes visible.
Private Sub AdjustScrollBar(BoxIndex As Long)
On Error GoTo ErrorTrap
Dim Index As Long
Dim Row As Long
Row = 0
For Index = ParameterBoxes.LBound To BoxIndex
If ParameterBoxes(Index).Visible Then Row = Row + 1
Next Index
EndRoutine:
ParameterFrameScrollBar.Value = Row - 1
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure adjusts this window to the selected query.
Private Sub AdjustWindow()
On Error GoTo ErrorTrap
Dim BoxIndex As Long
Dim FirstParameter As Long
Dim LastParameter As Long
Dim ParameterIndex As Long
Dim VisibleBoxes As Long
QueryParameters , , , FirstParameter, LastParameter
If Not (FirstParameter = NO_PARAMETER And LastParameter = NO_PARAMETER) Then
ParameterIndex = FirstParameter
VisibleBoxes = 0
BoxIndex = ParameterBoxes.LBound
Do While ParameterIndex <= LastParameter
If BoxIndex > ParameterBoxes.UBound Then
Load ParameterLabel(BoxIndex)
Load ParameterBoxes(BoxIndex)
ParameterLabel(BoxIndex).Top = (VisibleBoxes * (ParameterLabel(BoxIndex).Height * 1.75))
ParameterBoxes(BoxIndex).Top = ParameterLabel(BoxIndex).Top
End If
With QueryParameters(, ParameterIndex)
ParameterLabel(BoxIndex).Caption = .ParameterName & ":"
ParameterLabel(BoxIndex).Enabled = True
ParameterLabel(BoxIndex).ToolTipText = Left$(ParameterLabel(BoxIndex).Caption, Len(ParameterLabel(BoxIndex).Caption) - 1)
ParameterLabel(BoxIndex).Visible = .InputBoxIsVisible
ParameterBoxes(BoxIndex).Enabled = True
ParameterBoxes(BoxIndex).Locked = (.Mask = vbNullString)
ParameterBoxes(BoxIndex).MaxLength = Len(.Mask)
ParameterBoxes(BoxIndex).TabIndex = (OpenQueryButton.TabIndex + 1) + BoxIndex
ParameterBoxes(BoxIndex).Text = .DefaultValue & Mid$(.FixedMask, Len(.DefaultValue) + 1)
If Not Trim$(.Comments) = vbNullString Then ParameterBoxes(BoxIndex).ToolTipText = .Comments
ParameterBoxes(BoxIndex).Visible = .InputBoxIsVisible
If ParameterBoxes(BoxIndex).Visible Then
ParametersFrame.Enabled = True
VisibleBoxes = VisibleBoxes + 1
End If
End With
ParameterIndex = ParameterIndex + 1
BoxIndex = BoxIndex + 1
Loop
ParameterFrameScrollBar.Enabled = True
ParameterFrameScrollBar.Max = VisibleBoxes
ParameterFrameScrollBar.Value = 0
For BoxIndex = ParameterBoxes.LBound To ParameterBoxes.UBound
If ParameterBoxes(BoxIndex).Visible Then
ParameterBoxes(BoxIndex).SetFocus
Exit For
End If
Next BoxIndex
End If
ExecuteQueryButton.Enabled = ((Not (Query().Path = vbNullString)) And ConnectionOpened(Connection()))
If ExecuteQueryButton.Enabled And VisibleBoxes = 0 Then ExecuteQueryButton.SetFocus
If Not Query().Path = vbNullString Then
Me.Caption = App.Title & " " & ProgramVersion() & " - " & Query().Path
DisplayStatus "Query: " & Query().Path & vbCrLf
End If
QueryPathBox.Text = Unquote(Query().Path)
QueryPathBox.SelStart = 0
If Not QueryPathBox.Text = vbNullString Then QueryPathBox.SelStart = Len(QueryPathBox.Text) - 1
EndRoutine:
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure gives the command to display the specified/already loaded query.
Private Sub DisplayQuery(Optional Path As String = vbNullString)
On Error GoTo ErrorTrap
If Not BatchModeActive() Then
If Path = vbNullString Then
QueryParameters Query().Code
Else
QueryParameters Query(Unquote(Path)).Code
End If
End If
QueryResults , RemoveResults:=True
ResetWindow
AdjustWindow
If Settings().QueryAutoExecute Then GiveQueryCommand
EndRoutine:
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure gives the command to export the query result.
Private Sub GiveExportCommand()
On Error GoTo ErrorTrap
Dim EMail As EMailClass
Dim ExportPath As String
ExportPath = ExportPathBox.Text
If ExportPath = vbNullString Then
MsgBox "No export path specified.", vbExclamation
ElseIf Me.Visible Then
Screen.MousePointer = vbHourglass
ExportResultButton.Enabled = False
DisplayStatus "Busy exporting the query result..." & vbCrLf
ExportPath = FileSystemO().GetAbsolutePathName(Unquote(Trim$(ReplaceSymbols(ExportPath))))
If FileSystemO().FolderExists(FileSystemO().GetParentFolderName(ExportPath)) Then
If ExportResult(ExportPath) Then
If FileSystemO().FileExists(ExportPath) Then
If OpenResultAfterExportBox.Value = vbChecked Then
DisplayStatus "The export will be opened automatically..." & vbCrLf
CheckForAPIError ShellExecuteA(CLng(0), "open", ExportPath, vbNullString, vbNullString, SW_SHOWNORMAL)
End If
If CreateEMailWithExportAttachedBox.Value = vbChecked Then
DisplayStatus "Busy creating the e-mail containing the export..." & vbCrLf
Set EMail = New EMailClass
EMail.AddQueryResults ExportPath
Set EMail = Nothing
End If
End If
DisplayStatus "Finished export." & vbCrLf
Else
DisplayStatus "Export canceled." & vbCrLf
End If
Else
MsgBox "Invalid export path." & vbCr & "Current path: " & CurDir$(), vbExclamation
DisplayStatus "Invalid export path." & vbCrLf
End If
End If
EndRoutine:
ExportResultButton.Enabled = True
Screen.MousePointer = vbDefault
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure gives the command to excute the selected query with the specified parameters.
Private Sub GiveQueryCommand()
On Error GoTo ErrorTrap
If Not Query().Code = vbNullString Then
ExecuteQueryButton.Enabled = False
If ParametersValid(ParameterBoxes) Then
Screen.MousePointer = vbHourglass
DisplayStatus "Busy executing the query..." & vbCrLf
QueryResults , RemoveResults:=True
ExecuteQuery Query().Code
If ConnectionOpened(Connection()) Then
DisplayQueryResult QueryResultBox, ResultIndex:=0
If Connection().Errors.Count = 0 Then
If AutomaticallyExportResultBox.Value = vbChecked Then GiveExportCommand
Else
DisplayStatus ErrorListText(Connection().Errors)
End If
Connection , , Reset:=True
End If
End If
End If
EndRoutine:
ExecuteQueryButton.Enabled = ((Not (Query().Path = vbNullString)) And ConnectionOpened(Connection()))
Screen.MousePointer = vbDefault
If (Settings().QueryAutoClose) Or (Not ProcessSessionList() = vbNullString) Then Unload Me
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure sets this window to interactive batch mode.
Private Sub PutWindowInBatchMode()
On Error GoTo ErrorTrap
AutomaticallyExportResultBox.Enabled = False
CreateEMailWithExportAttachedBox.Enabled = False
ExportFrame.Enabled = False
ExportResultButton.Enabled = False
ExportResultToLabel.Enabled = False
OpenResultAfterExportBox.Enabled = False
OpenQueryButton.Enabled = False
QueryLabel.Enabled = False
QueryPathBox.Enabled = False
QueryResultBox.Enabled = False
ResultFrame.Enabled = False
SelectExportPathButton.Enabled = False
SelectQueryButton.Enabled = False
ExportPathBox.Text = vbNullString
ExecuteQueryButton.Caption = "&Execute Batch"
ExecuteQueryButton.ToolTipText = "Click here to execute the batch with the specified parameters."
EndRoutine:
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure resets this window.
Private Sub ResetWindow()
On Error GoTo ErrorTrap
Dim Index As Long
AutomaticallyExportResultBox.Enabled = True
CreateEMailWithExportAttachedBox.Enabled = True
ExecuteQueryButton.Enabled = False
ExportFrame.Enabled = True
ExportResultButton.Enabled = True
ExportResultToLabel.Enabled = True
OpenQueryButton.Enabled = True
OpenResultAfterExportBox.Enabled = True
ParameterFrameScrollBar.Enabled = False
ParametersFrame.Enabled = False
QueryLabel.Enabled = True
QueryPathBox.Enabled = True
QueryResultBox.Enabled = True
ResultFrame.Enabled = True
SelectExportPathButton.Enabled = True
SelectQueryButton.Enabled = True
QueryResultBox.Text = vbNullString
AutomaticallyExportResultBox.ToolTipText = "If this box is checked, the query result will be exported to the specified path."
CreateEMailWithExportAttachedBox.ToolTipText = "If this box is checked, an e-mail with the exported query result will be created."
ExecuteQueryButton.ToolTipText = "Click here to execute the query with the specified parameters."
ExportPathBox.ToolTipText = "Here the path to which the query result will exported to can be specified."
ExportResultButton.ToolTipText = "Click here to export the query result to the specified path."
OpenQueryButton.ToolTipText = "Click here to the open the specified query file."
OpenResultAfterExportBox.ToolTipText = "If this box is checked, the exported query result will be opened."
QueryPathBox.ToolTipText = "Here a query file's path can be specified."
QueryResultBox.ToolTipText = "The query result is displayed here. Press the Control + Page Up or Page Down keys to browse between multiple query results."
SelectExportPathButton.ToolTipText = "Click here to open a window to browse to a folder for the export file."
SelectQueryButton.ToolTipText = "Click here to open a window to browse to a query file."
StatusBox.ToolTipText = "The status information is displayed here. Right click inside the text for options."
For Index = ParameterBoxes.LBound To ParameterBoxes.UBound
ParameterLabel(Index).Caption = "Parameter:"
ParameterLabel(Index).Enabled = False
ParameterLabel(Index).ToolTipText = ParameterLabel(Index).Caption
ParameterBoxes(Index).Enabled = False
ParameterBoxes(Index).Text = vbNullString
ParameterBoxes(Index).ToolTipText = "Enter a value for the parameter here."
If Index > ParameterBoxes.LBound Then
Unload ParameterLabel(Index)
Unload ParameterBoxes(Index)
End If
Next Index
Me.Caption = App.Title & " " & ProgramVersion()
EndRoutine:
If Settings().BatchInteractive Then PutWindowInBatchMode
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure closes this window.
Private Sub CloseMenu_Click()
On Error GoTo ErrorTrap
Unload Me
EndRoutine:
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure gives the command to execute the selected query with the specified parameters.
Private Sub ExecuteQueryButton_Click()
On Error GoTo ErrorTrap
If Settings().BatchInteractive Then
If ParametersValid(ParameterBoxes) Then
AbortInteractiveBatch AbortBatch:=False
Me.Enabled = False
ExecuteQueryButton.Enabled = False
End If
Else
GiveQueryCommand
End If
EndRoutine:
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure gives the command to the export the query result.
Private Sub ExportResultButton_Click()
On Error GoTo ErrorTrap
GiveExportCommand
EndRoutine:
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure gives the command to diplay any query that has been loaded while starting this program.
Private Sub Form_Activate()
On Error GoTo ErrorTrap
If BatchModeActive() Then
AdjustWindow
Else
If Not Trim$(Command$()) = vbNullString Then DisplayStatus "Command line: " & Command$() & vbCrLf
If Not ProcessSessionList() = vbNullString Then DisplayStatus "Session list: " & ProcessSessionList() & vbCrLf
DisplayConnectionStatus
If Not Query().Path = vbNullString Then DisplayQuery Query().Path
End If
EndRoutine:
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure initializes this window when it is opened.
Private Sub Form_Load()
On Error GoTo ErrorTrap
If Not BatchModeActive() And Not CommandLineArguments().QueryPath = vbNullString Then Query CommandLineArguments().QueryPath
ResetWindow
DisplayStatus , NewBox:=StatusBox
With Settings()
ExportPathBox.Text = .ExportDefaultPath
AutomaticallyExportResultBox.Value = vbUnchecked
CreateEMailWithExportAttachedBox.Value = vbUnchecked
OpenResultAfterExportBox.Value = vbUnchecked
If .ExportAutoOpen Then OpenResultAfterExportBox.Value = vbChecked
If Not .ExportDefaultPath = vbNullString Then AutomaticallyExportResultBox.Value = vbChecked
If Not (.ExportRecipient = vbNullString And .ExportCCRecipient = vbNullString) Then CreateEMailWithExportAttachedBox.Value = vbChecked
End With
EndRoutine:
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure closes this window after confirmation from the user.
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
On Error GoTo ErrorTrap
Dim Choice As Long
With Settings()
If Not .QueryAutoClose Then
If UnloadMode = vbFormControlMenu Then
If (AbortInteractiveBatch() And InteractiveBatchModeActive()) Or Not BatchModeActive() Then
Choice = MsgBox("Close this program?", vbQuestion Or vbYesNo Or vbDefaultButton2)
Select Case Choice
Case vbNo
Cancel = CInt(True)
Case vbYes
If Not ProcessSessionList() = vbNullString Then AbortSessions NewAbortSessions:=True
Cancel = CInt(False)
End Select
End If
End If
End If
End With
EndRoutine:
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure gives the command to display information about this program.
Private Sub InformationMenu_Click()
On Error GoTo ErrorTrap
DisplayProgramInformation
EndRoutine:
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure gives the command to open the query at the specified path.
Private Sub OpenQueryButton_Click()
On Error GoTo ErrorTrap
If Not QueryPathBox.Text = vbNullString Then DisplayQuery QueryPathBox.Text
EndRoutine:
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure selects the contents of the activated parameter box.
Private Sub ParameterBoxes_GotFocus(Index As Integer)
On Error GoTo ErrorTrap
With ParameterBoxes(Index)
If .Top - .Height < 0 Or .Top > ParameterBoxContainer.ScaleHeight Then AdjustScrollBar CLng(Index)
.SelStart = 0
.SelLength = Len(.Text)
End With
EndRoutine:
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure filters the user's keystrokes in a parameter box.
Private Sub ParameterBoxes_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
On Error GoTo ErrorTrap
If Not Shift = Asc(vbNullChar) Then
If Not ((KeyCode = vbKeyF4) And (Shift And vbAltMask) = vbAltMask) Then
KeyCode = Asc(vbNullChar)
Shift = Asc(vbNullChar)
End If
End If
EndRoutine:
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure handles the user's input in a parameter box.
Private Sub ParameterBoxes_KeyPress(Index As Integer, KeyAscii As Integer)
On Error GoTo ErrorTrap
Dim Character As String
Dim CursorPosition As Long
Dim FixedInputCharacter As String
Dim MaskCharacter As String
Dim Text As String
If Not KeyAscii = vbMenuAccelCtrlC Then
With ParameterBoxes(Index)
Character = vbNullString
Select Case KeyAscii
Case vbKeyBack
If .SelStart > 0 Then
CursorPosition = .SelStart
Character = Mid$(QueryParameters(, CLng(Index)).FixedMask, CursorPosition, 1)
End If
Case vbMenuAccelCtrlV
If .SelLength = 0 Then
.Text = Clipboard.GetText(vbCFText)
Else
.SelText = Clipboard.GetText(vbCFText)
End If
Case vbMenuAccelCtrlX
If .SelLength = 0 Then
Clipboard.SetText .Text, vbCFText
.Text = QueryParameters(, CLng(Index)).FixedMask
Else
Clipboard.SetText .SelText, vbCFText
.SelText = QueryParameters(, CLng(Index)).FixedMask
End If
Case Else
Character = UCase$(Chr$(KeyAscii))
CursorPosition = .SelStart + 1
With QueryParameters(, CLng(Index))
FixedInputCharacter = Mid$(.FixedInput, CursorPosition, 1)
MaskCharacter = Mid$(.Mask, CursorPosition, 1)
End With
If Not ParameterMaskCharacterValid(Character, MaskCharacter, FixedInputCharacter) = vbNullString Then Character = vbNullString
End Select
If CursorPosition > 0 And CursorPosition <= Len(QueryParameters(, CLng(Index)).Mask) Then
Text = .Text & Mid$(QueryParameters(, CLng(Index)).FixedMask, Len(.Text) + 1)
Mid$(Text, CursorPosition, 1) = Character
.Text = Text
If KeyAscii = vbKeyBack Then .SelStart = CursorPosition - 1 Else .SelStart = CursorPosition
End If
KeyAscii = Asc(vbNullChar)
End With
End If
EndRoutine:
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure clears the parameter box when the user presses the delete button.
Private Sub ParameterBoxes_KeyUp(Index As Integer, KeyCode As Integer, Shift As Integer)
On Error GoTo ErrorTrap
If KeyCode = vbKeyDelete Then
With QueryParameters(, CLng(Index))
ParameterBoxes(Index).Text = .DefaultValue & Mid$(.FixedMask, Len(.DefaultValue) + 1)
End With
End If
EndRoutine:
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure selects the activated parameter box' contents.
Private Sub ParameterBoxes_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error GoTo ErrorTrap
ParameterBoxes(Index).SelStart = 0
ParameterBoxes(Index).SelLength = Len(ParameterBoxes(Index).Text)
EndRoutine:
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure moves the parameter boxes when the button on the scrollbar is moved.
Private Sub ParameterFrameScrollBar_Change()
On Error GoTo ErrorTrap
Dim Index As Long
Dim Row As Long
Row = 0
For Index = ParameterBoxes.LBound To ParameterBoxes.UBound
ParameterLabel(Index).Top = (Row - ParameterFrameScrollBar.Value) * (ParameterLabel(Index).Height * 1.75)
ParameterBoxes(Index).Top = ParameterLabel(Index).Top
If Not QueryParameters(, Index).ParameterName = vbNullString Then Row = Row + 1
Next Index
EndRoutine:
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure opens the first of one or more files that have been dragged into the query path box.
Private Sub QueryPathBox_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error GoTo ErrorTrap
If Data.Files.Count > 0 Then DisplayQuery Data.Files.Item(1)
EndRoutine:
Exit Sub
ErrorTrap:
If HandleError(ReturnPreviousChoice:=False) = vbIgnore Then Resume EndRoutine
If HandleError() = vbRetry Then Resume
End Sub
'This procedure processes the user's keystrokes in the query result box.
Private Sub QueryResultBox_KeyUp(KeyCode As Integer, Shift As Integer)
On Error GoTo ErrorTrap
Dim FirstResult As Long
Dim LastResult As Long
Static ResultIndex As Long
If (Shift And vbCtrlMask) = vbCtrlMask Then