lifeson
09-19-2007, 08:12 AM
In the attached workbook I have a problem where on one of the forms if the user clicks the select button and no item in the listbox on the form is selected an error message I have set does not appear as expected.
I have stripped as much of the rubbish out as I can so it may be a bit buggy:bug:
But if you click the button on sheet1 and on the user form
select the following as they appear
New full system
Heating Only
Worcester Greenstar 24Ri
A form will appear showing packs linked that component.
If you use the select button without choosing an item in the list I would have expected the error message to appear from this code:
Private Sub cmdSelect_Click()
Dim iItem As Double
Dim val As String
Dim id As String
If lstAcc.ListIndex = -1 Then
msg = "No item has been selected," & vbNewLine
msg = msg & "Select an item from the list to add"
ans = MsgBox(msg, vbExclamation)
Else
For iItem = 0 To lstAcc.ListCount - 1
If lstAcc.Selected(iItem) = True Then
id = lstAcc.list(iItem) ' identifies pack number
val = lstAcc.list(iItem) ' identifies pack description
If frmQty Is Nothing Then Set frmQty = New FrmAccQty
frmQty.SelectedValue = val
frmQty.Show
lstAcc.Selected(iItem) = False
End If
Next
End If
End Sub
Thanks to XLD and others for getting me this far with this bit of work :bow: :bow:
I have stripped as much of the rubbish out as I can so it may be a bit buggy:bug:
But if you click the button on sheet1 and on the user form
select the following as they appear
New full system
Heating Only
Worcester Greenstar 24Ri
A form will appear showing packs linked that component.
If you use the select button without choosing an item in the list I would have expected the error message to appear from this code:
Private Sub cmdSelect_Click()
Dim iItem As Double
Dim val As String
Dim id As String
If lstAcc.ListIndex = -1 Then
msg = "No item has been selected," & vbNewLine
msg = msg & "Select an item from the list to add"
ans = MsgBox(msg, vbExclamation)
Else
For iItem = 0 To lstAcc.ListCount - 1
If lstAcc.Selected(iItem) = True Then
id = lstAcc.list(iItem) ' identifies pack number
val = lstAcc.list(iItem) ' identifies pack description
If frmQty Is Nothing Then Set frmQty = New FrmAccQty
frmQty.SelectedValue = val
frmQty.Show
lstAcc.Selected(iItem) = False
End If
Next
End If
End Sub
Thanks to XLD and others for getting me this far with this bit of work :bow: :bow: