ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Form/Listboxes -- problems (https://www.excelbanter.com/excel-programming/297499-form-listboxes-problems.html)

Stuart[_5_]

Form/Listboxes -- problems
 
I have an initial form, containing a label, four listboxes an OK
and a Cancel button. The form is designed to get the user's
print options. Here is the module code:

With GetUserPrintOptions
.Show
If .OkButton.Tag = "Selected" Then
If .ListBox1.Selected(0) Then
Global_PrintAllBooks_Sheets = True
End If
If .ListBox2.Selected(0) Then
HideCols = True
With GetUserHideColumnOptions
If .ListBox1.Selected(0) = True Then
Global_HideSameCols = True
End If
End With
End If
If .ListBox3.Selected(0) Then
PrintZeroPages = True
With GetUserPrintZeroPagesOptions
If .ListBox1.Selected(0) = True Then
Global_PrintZeroPages = True
End If
End With
End If
If .ListBox4.Selected(0) Then
PrintBlankPages = True
With GetUserPrintBlankPagesOptions
If .ListBox1.Selected(0) = True Then
Global_PrintBlankPages = True
End If
End With
End If
Else
'Cancel Button was pressed so set defaults
Global_PrintAllBooks_Sheets = False
Global_HideCols = False
Global_PrintZeroPages = False
Global_PrintBlankPages = False
End If
End With

Listboxes 2-4 if Selected, will cause further forms to be presented
where the user is asked if they wish their choice in the
GetUserPrintOptions listbox, is to apply to all worksheets in all
workbooks. If so, then set the relevent Global variable to True.

Problem: I cannot execute this code cleanly.
Quite often I am returned to the original Form, only to find that
one of the listboxes (previously highlighted in blue) has suddenly
cleared itself. I have to repeat the selection of that listbox. Often
this process is repeated with another selected listbox before all
selections are displayed correctly, and I can press OK to exit the
form.

Would be grateful for help, please.

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.674 / Virus Database: 436 - Release Date: 02/05/2004



BOHICA

Form/Listboxes -- problems
 
"Stuart" wrote in message ...
I have an initial form, containing a label, four listboxes an OK
and a Cancel button. The form is designed to get the user's
print options. Here is the module code:

With GetUserPrintOptions
.Show
If .OkButton.Tag = "Selected" Then
If .ListBox1.Selected(0) Then
Global_PrintAllBooks_Sheets = True
End If
If .ListBox2.Selected(0) Then
HideCols = True
With GetUserHideColumnOptions
If .ListBox1.Selected(0) = True Then
Global_HideSameCols = True
End If
End With
End If
If .ListBox3.Selected(0) Then
PrintZeroPages = True
With GetUserPrintZeroPagesOptions
If .ListBox1.Selected(0) = True Then
Global_PrintZeroPages = True
End If
End With
End If
If .ListBox4.Selected(0) Then
PrintBlankPages = True
With GetUserPrintBlankPagesOptions
If .ListBox1.Selected(0) = True Then
Global_PrintBlankPages = True
End If
End With
End If
Else
'Cancel Button was pressed so set defaults
Global_PrintAllBooks_Sheets = False
Global_HideCols = False
Global_PrintZeroPages = False
Global_PrintBlankPages = False
End If
End With

Listboxes 2-4 if Selected, will cause further forms to be presented
where the user is asked if they wish their choice in the
GetUserPrintOptions listbox, is to apply to all worksheets in all
workbooks. If so, then set the relevent Global variable to True.

Problem: I cannot execute this code cleanly.
Quite often I am returned to the original Form, only to find that
one of the listboxes (previously highlighted in blue) has suddenly
cleared itself. I have to repeat the selection of that listbox. Often
this process is repeated with another selected listbox before all
selections are displayed correctly, and I can press OK to exit the
form.

Would be grateful for help, please.

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.674 / Virus Database: 436 - Release Date: 02/05/2004





Unfortunately I do not know a clean way to fix this, but I can offer a
temporary logic fix. When values are entered, have the value stored
to a variable in the form, and when the code switches back to the
form, it re-states those values to the form during the code execution.
If that doesn't help, at least it puts this to the top of the list
here.

Stuart[_5_]

Form/Listboxes -- problems
 
Many thanks, I'll give it a go.

Regards.

"BOHICA" wrote in message
om...
"Stuart" wrote in message

...
I have an initial form, containing a label, four listboxes an OK
and a Cancel button. The form is designed to get the user's
print options. Here is the module code:

With GetUserPrintOptions
.Show
If .OkButton.Tag = "Selected" Then
If .ListBox1.Selected(0) Then
Global_PrintAllBooks_Sheets = True
End If
If .ListBox2.Selected(0) Then
HideCols = True
With GetUserHideColumnOptions
If .ListBox1.Selected(0) = True Then
Global_HideSameCols = True
End If
End With
End If
If .ListBox3.Selected(0) Then
PrintZeroPages = True
With GetUserPrintZeroPagesOptions
If .ListBox1.Selected(0) = True Then
Global_PrintZeroPages = True
End If
End With
End If
If .ListBox4.Selected(0) Then
PrintBlankPages = True
With GetUserPrintBlankPagesOptions
If .ListBox1.Selected(0) = True Then
Global_PrintBlankPages = True
End If
End With
End If
Else
'Cancel Button was pressed so set defaults
Global_PrintAllBooks_Sheets = False
Global_HideCols = False
Global_PrintZeroPages = False
Global_PrintBlankPages = False
End If
End With

Listboxes 2-4 if Selected, will cause further forms to be presented
where the user is asked if they wish their choice in the
GetUserPrintOptions listbox, is to apply to all worksheets in all
workbooks. If so, then set the relevent Global variable to True.

Problem: I cannot execute this code cleanly.
Quite often I am returned to the original Form, only to find that
one of the listboxes (previously highlighted in blue) has suddenly
cleared itself. I have to repeat the selection of that listbox. Often
this process is repeated with another selected listbox before all
selections are displayed correctly, and I can press OK to exit the
form.

Would be grateful for help, please.

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.674 / Virus Database: 436 - Release Date: 02/05/2004





Unfortunately I do not know a clean way to fix this, but I can offer a
temporary logic fix. When values are entered, have the value stored
to a variable in the form, and when the code switches back to the
form, it re-states those values to the form during the code execution.
If that doesn't help, at least it puts this to the top of the list
here.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.674 / Virus Database: 436 - Release Date: 02/05/2004




All times are GMT +1. The time now is 08:47 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com