UserForm will not appear

L

Luke

Here is my code:

Private Sub CommandButton1_Click()
UserForm1.Show
End Sub

That's it. But every time I click on CommandButton1, I get this error:
"Application-define or object-defined error". The user form worked up until
today and I can't think of anything I've done to affect it. Can anyone help
me fix this?
 
R

Ryan H

I can't seem to recreate the error.

Do you have any code in the Userform1 Intialize Event? If so, post the code
in that event so we can try to fix the bug.
 
L

Luke

Sure. Here's the code from the initialize event:

Private Sub UserForm_Initialize()

' Filling the State and Weekday list boxes
With ComboBox6
.AddItem "Alabama"
.AddItem "Alaska"
.AddItem "Arizona"
.AddItem "Arkansas"
.AddItem "California"
.AddItem "Colorado"
.AddItem "Connecticut"
.AddItem "DC"
.AddItem "Delaware"
.AddItem "Florida"
.AddItem "Georgia"
.AddItem "Hawaii"
.AddItem "Idaho"
.AddItem "Illinois"
.AddItem "Indiana"
.AddItem "Iowa"
.AddItem "Kansas"
.AddItem "Kentucky"
.AddItem "Louisiana"
.AddItem "Maine"
.AddItem "Maryland"
.AddItem "Massachusetts"
.AddItem "Michigan"
.AddItem "Minnesota"
.AddItem "Mississippi"
.AddItem "Missouri"
.AddItem "Montana"
.AddItem "Nebraska"
.AddItem "Nevada"
.AddItem "New Hampshire"
.AddItem "New Jersey"
.AddItem "New Mexico"
.AddItem "New York"
.AddItem "North Carolina"
.AddItem "North Dakota"
.AddItem "Ohio"
.AddItem "Oklahoma"
.AddItem "Oregon"
.AddItem "Pennsylvania"
.AddItem "Rhode Island"
.AddItem "South Carolina"
.AddItem "South Dakota"
.AddItem "Tennessee"
.AddItem "Texas"
.AddItem "Utah"
.AddItem "Vermont"
.AddItem "Virginia"
.AddItem "Washington"
.AddItem "West Virginia"
.AddItem "Wisconsin"
.AddItem "Wyoming"
End With
With ComboBox7
.AddItem "Sunday"
.AddItem "Monday"
.AddItem "Tuesday"
.AddItem "Wednesday"
.AddItem "Thursday"
.AddItem "Friday"
.AddItem "Saturday"
End With
' Selecting the first items in each list
ComboBox6.ListIndex = 0
ComboBox7.ListIndex = 0
' Setting MaxDate and MinDate
DTPicker2.MaxDate = Worksheets("Claims").Range("A1").Value
DTPicker2.MinDate = "1/1/2004"
DTPicker1.MaxDate = Worksheets("Claims").Range("A1").Value
DTPicker1.MinDate = "1/1/2004"
DTPicker1.Value = Worksheets("Claims").Range("B1").Value
DTPicker2.Value = Worksheets("Claims").Range("A1").Value
' Pre-selecting client type
UserForm1.OptionButton1.Value = False
UserForm1.OptionButton2.Value = False
UserForm1.OptionButton3.Value = True
UserForm1.OptionButton4.Value = False
With ComboBox9
.AddItem "Open Claims"
.AddItem "Closed Claims"
End With
ComboBox9.ListIndex = 0
With ComboBox1
.RowSource = Worksheets("Claims").Range("D3:D" & _
Worksheets("Claims").Range("C1").Value)
End With
End Sub

Not the fanciest bit of code, but it was doing what I needed until just
recently.
 
L

Luke

Nevermind. I changed the ComboBox1 part (where I tried to set the RowSource)
to a small For-Next loop and added each item I wanted. I also cleared out
the RowSource value that was showing in the ComboBox1 properties. All
appears to work now as it should.

Sorry for taking up your time. Thank you for being willing to help.
 

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