listbox question - automatic selection if only one entry

B

bryan

I am using a listbox to display endorsment forms pertinant to each line of
business. When selections are made, I insert these end. forms to the
template. For 1 line of business, there is only 1 form.
I have code at the end which looks at the count value and returns if 0 or 1,
however there is no value if only 1 entry
How can I auto select this?
Here's a snippet of code:

Public POL As String
Private Sub UserForm_Activate()
co = Left(POL, 2)
prfx = Mid(POL, 4, 2)
policystate = Right(POL, 2)
TB1.Text = prfx

Select Case policystate
Case "WA"

If prfx = "CF" Then
ListBox1.AddItem ("IL0953")
ListBox1.ListIndex = 0

ElseIf prfx = "CP" Then
ListBox1.AddItem ("CG2173")
ListBox1.AddItem ("IL0953")
ListBox1.AddItem ("CL0610")
ListBox1.ListIndex = 0

ElseIf prfx = "GL" Then
ListBox1.AddItem ("CG2173")
ListBox1.ListIndex = 0
..
..etc
..
If ListBox1.ListCount = 0 Or ListBox1.ListCount = 1 Then
Call CommandButton1_Click
End If
 

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