Form/Listboxes -- problems

S

Stuart

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.
 
B

BOHICA

Stuart said:
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.




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.
 
S

Stuart

Many thanks, I'll give it a go.

Regards.

BOHICA said:
"Stuart" <[email protected]> wrote in message




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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top