C
Craig
I have created a userform containing 1 textbox, 2 comboboxes, and 1
commandbutton.
My problem is this, when data is entered in the textbox or comboboxes it is
put into their variables but when I click on the commandbutton the variables
have no data in them anymore.
I have a test msgbox that displays the variables and the data is there, but
the test msgbox in the command button shows the variables as empty.
I have included the entire code below:
Private Sub TextBox1_Change()
xbatch = TextBox1
xval = 1
End Sub
Private Sub ComboBox1_Change()
xweek = ComboBox1
xval = 2
MsgBox (xweek & "-" & xval)
End Sub
Private Sub ComboBox2_Change()
xdow = ComboBox2
xval = 3
End Sub
Private Sub CommandButton1_Click()
' If xval = 3 Then
MsgBox (xbatch & ", " & xweek & ", " & xdow)
' Summary_of_Orders_Report xbatch, xweek, xdow
' End If
' MsgBox ("You must enter a value in all the fields" & vbCrLf & "xval = "
& xval)
End Sub
Private Sub userform_initialize()
'Set up the public variables the macro will use
Dim x, xval As Integer
Dim xbatch, xweek, xdow As String
'Initialize the week and day combo boxes by adding the correct values to
them
x = 1
For x = 1 To 52 Step 1 'The week number
ComboBox1.AddItem (x)
Next x
ComboBox2.AddItem ("Monday")
ComboBox2.AddItem ("Tuesday")
ComboBox2.AddItem ("Wednesday")
ComboBox2.AddItem ("Thursday")
ComboBox2.AddItem ("Friday")
End Sub
commandbutton.
My problem is this, when data is entered in the textbox or comboboxes it is
put into their variables but when I click on the commandbutton the variables
have no data in them anymore.
I have a test msgbox that displays the variables and the data is there, but
the test msgbox in the command button shows the variables as empty.
I have included the entire code below:
Private Sub TextBox1_Change()
xbatch = TextBox1
xval = 1
End Sub
Private Sub ComboBox1_Change()
xweek = ComboBox1
xval = 2
MsgBox (xweek & "-" & xval)
End Sub
Private Sub ComboBox2_Change()
xdow = ComboBox2
xval = 3
End Sub
Private Sub CommandButton1_Click()
' If xval = 3 Then
MsgBox (xbatch & ", " & xweek & ", " & xdow)
' Summary_of_Orders_Report xbatch, xweek, xdow
' End If
' MsgBox ("You must enter a value in all the fields" & vbCrLf & "xval = "
& xval)
End Sub
Private Sub userform_initialize()
'Set up the public variables the macro will use
Dim x, xval As Integer
Dim xbatch, xweek, xdow As String
'Initialize the week and day combo boxes by adding the correct values to
them
x = 1
For x = 1 To 52 Step 1 'The week number
ComboBox1.AddItem (x)
Next x
ComboBox2.AddItem ("Monday")
ComboBox2.AddItem ("Tuesday")
ComboBox2.AddItem ("Wednesday")
ComboBox2.AddItem ("Thursday")
ComboBox2.AddItem ("Friday")
End Sub