I have a sub-form (it is a continuous form) that was previously bound to a query in an Access database, now I am un-binding all the controls on the form to link the form to a SQL Server database.
There are 3 combo boxes on the form, with the following Row Sources:
- Row source type of
Value List
. Table/Query
.Value List
withYes
orNo
values.
All 3 combo boxes populate correctly, but when changing the value in Combo box #3, everything freezes, and I have to right click to force the Parent form to close. This does not happen when I change the values in the other two combo boxes.
I have tried changing the number of columns on the combo box from two ("Yes";-1;"No";0
) to one ("YES";"NO"
), changing the row source type to Table/Query
and populating the combo box via a stored procedure, I added the on click
event and put a break point within the event. When I change the value, the freeze occurs before entering the on click
sub.
Private Sub Form_Load()
On Error GoTo Err_Handler
Dim strError As String
Dim lngCompanyID As Long
Dim lngTabulationID As Long
Dim dblTtlCEDEPosition As Double
Dim dblTtlTotalBNTreasury As Double
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim rsCmbJob As ADODB.Recordset
Dim rsCmbClass As ADODB.Recordset
Dim rsYesNo As ADODB.Recordset
lngTabulationID = KeyTabulationID
lngCompanyID = mstrCompanyID
Set cnn = New ADODB.Connection
cnn.Open gconConnectOLEDB
Set rs = New ADODB.Recordset
With rs
Set .ActiveConnection = cnn
.Source = "EXEC spLoadTabulatlatedClassInfo " & lngTabulationID
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.CursorLocation = adUseClient
.Open
End With
Set rs.ActiveConnection = Nothing
Set Me.Recordset = rs
Me.txtTabulationID.ControlSource = "TabulationID"
Me.txtJobID.ControlSource = "JobID"
Me.txtPlanID.ControlSource = "PlanID"
Me.cboClass.ControlSource = "Class"
Me.txtRatio.ControlSource = "Ratio"
Me.txtVotes.ControlSource = "Votes"
Me.cboYesNo.ControlSource = "YesNo"
Me.txtLineItem.ControlSource = "LineItem"
Me.cboJobName.ControlSource = "JobName"
Set rsCmbClass = New ADODB.Recordset
With rsCmbClass
Set .ActiveConnection = cnn
.Source = "EXEC spLoadClassComboLoad " & lngCompanyID
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.CursorLocation = adUseClient
.Open
End With
Set rsCmbClass.ActiveConnection = Nothing
Set Me.cboClass.Recordset = rsCmbClass
' Set rsYesNo = New ADODB.Recordset
' With rsYesNo
' Set .ActiveConnection = cnn
' .Source = "EXEC uspLoadYesNoCombo"
' .LockType = adLockOptimistic
' .CursorType = adOpenKeyset
' .CursorLocation = adUseClient
' .Open
' End With
' Set rsYesNo.ActiveConnection = Nothing
' Set Me.cboYesNo.Recordset = rsCmbApplyRatio
Exit_Handler:
On Error Resume Next
If LenB(strError) Then
MsgBox strError, vbCritical, Me.Name & ".FormLoad"
End If
If Not (rs Is Nothing) Then
rs.Close
Set rs = Nothing
End If
If Not (rsCmbJob Is Nothing) Then
rsCmbJob.Close
Set rsCmbJob = Nothing
End If
If Not (rsCmbClass Is Nothing) Then
rsCmbClass.Close
Set rsCmbClass = Nothing
End If
' If Not (rsYesNo Is Nothing) Then
' rsYesNo.Close
' Set rsYesNo = Nothing
' End If
If Not (cnn Is Nothing) Then
If Not (cnn.State = adStateClosed) Then cnn.Close
Set cnn = Nothing
End If
Exit Sub
Err_Handler:
strError = "Error " & Err.Number & ": " & Err.Description
Resume Exit_Handler
End Sub
I encounter this same issue on other sub-forms where there is a Yes/No combo box.
Any help will be appreciated!