I have an application that connects to a DSN and generates a report based on a combobox for "Item Number" and a set of list controls for date range. The combobox is populated by a recordset:
Private Sub PopulateItemNumbers()
On Error GoTo errhandler
Set rs = New ADODB.Recordset
rs.Open "select distinct ITM_CD from GM_ITM ", cn, adOpenForwardOnly, adLockOptimistic
cboItemNo.Clear
Do While Not rs.EOF
cboItemNo.AddItem rs(0)
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Exit Sub
errhandler:
lblProcessing.Caption = ""
MsgBox "Error occured while populating Item Codes List control" & vbCrLf & _
Err.Number & ":" & Err.Description, vbCritical
If rs.State = adStateOpen Then
rs.Close
End If
Exit Sub
End Sub
...the combobox has "CausesValidation" set to true, I'm using a routine to validate that the box is not left empty called cboItemNo_Validate that looks like:
Private Sub cboItemNo_Validate(Cancel As Boolean)
If cboItemNo.Text <> "" Then
Cancel = ValidateCombo(cboItemNo)
If Cancel = True Then
MsgBox "Invalid Selection, Select Item from the List"
cboItemNo.SetFocus
Exit Sub
End If
Else
MsgBox "Item Number cannot be Empty"
Cancel = True
cboItemNo.SetFocus
Exit Sub
End If
End Sub
...even when I enter a valid entry the combobox gives me the message box,
"Invalid Selection, Select Item from the List"
...the strange thing is that this application worked for years and then all of the sudden stopped working? Is there some limit on the number of records that can be brought up in a combobox? We currently have 30K+.... Inside the form, whenever I go to select another control to genrerate the report the combobox attempts to validate, and I get the message?
Private Sub PopulateItemNumbers()
On Error GoTo errhandler
Set rs = New ADODB.Recordset
rs.Open "select distinct ITM_CD from GM_ITM ", cn, adOpenForwardOnly, adLockOptimistic
cboItemNo.Clear
Do While Not rs.EOF
cboItemNo.AddItem rs(0)
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Exit Sub
errhandler:
lblProcessing.Caption = ""
MsgBox "Error occured while populating Item Codes List control" & vbCrLf & _
Err.Number & ":" & Err.Description, vbCritical
If rs.State = adStateOpen Then
rs.Close
End If
Exit Sub
End Sub
...the combobox has "CausesValidation" set to true, I'm using a routine to validate that the box is not left empty called cboItemNo_Validate that looks like:
Private Sub cboItemNo_Validate(Cancel As Boolean)
If cboItemNo.Text <> "" Then
Cancel = ValidateCombo(cboItemNo)
If Cancel = True Then
MsgBox "Invalid Selection, Select Item from the List"
cboItemNo.SetFocus
Exit Sub
End If
Else
MsgBox "Item Number cannot be Empty"
Cancel = True
cboItemNo.SetFocus
Exit Sub
End If
End Sub
...even when I enter a valid entry the combobox gives me the message box,
"Invalid Selection, Select Item from the List"
...the strange thing is that this application worked for years and then all of the sudden stopped working? Is there some limit on the number of records that can be brought up in a combobox? We currently have 30K+.... Inside the form, whenever I go to select another control to genrerate the report the combobox attempts to validate, and I get the message?