Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 2165

Status
Not open for further replies.

Brambojr

Technical User
Oct 26, 2000
73
US
I have a main form where the user enters a few tidbits of information. Based on the type of meeting selected a subform will show the appropriate number of combo boxes. All of that works beautifully.

However, if a combo box has a value I can't ater set it to .visible = False (if a different and smaller meeting is then selected). It gives me "Error: You can't hide a control that has the focus. (2165)" Anyone have any ideas?

My theory is that one of the controls on the subform has focus in addition to a field on the main form - if so how do I fix that? Brambojr
 
Ok, I now know that the problem is that the control in the subform has focus within the subform, and I need to get it to lose that focus. There are no controls to pass it to, I can use that work around, but would prefer something more elegant.

any ideas?

I know a few months back before I tried to do all of this I would have loved someone to drop this code on me. Here it is for anyone doing something similar - or qualified enough to offer improvement.

Private Sub cboSession_AfterUpdate()

Me.cboTrainer.Value = Null
Me.cboTrainer.Requery
Me.cboTrainer.SetFocus

Dim intI As Integer
Dim intTot As Integer

' Fill the existing tabs on a Tab control with the
' values from the selected field
On Error GoTo HandleErrors

If Me.rdoOverSize.Value = -1 Then
intTot = Me.sfrmAttendees.Form.Controls.Count
Else
intTot = Nz(Me.txtSize.Value, 0)
End If

Me.Painting = False

For intI = 0 To Me.sfrmAttendees.Form.Controls.Count - 1
If intI < intTot Then
Me!sfrmAttendees.Form.Controls.Item(intI).Visible = True
Else
Me!sfrmAttendees.Form.Controls.Item(intI).Value = Null
Me!sfrmAttendees.Form.Controls.Item(intI).Visible = False
End If
Next intI


ExitHere:
On Error Resume Next
rst.Close
Me.Painting = True
Exit Sub

HandleErrors:
Select Case Err.Number
Case Else
MsgBox &quot;Error: &quot; & Err.Description & _
&quot; (&quot; & Err.Number & &quot;)&quot;
End Select
Resume ExitHere
End Sub Brambojr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top