I hide and show two command buttons ([cmdEnterJD] and [cmdAllReqns]) on my main form. This was working fine until I added a hyperlink to one of the tabbed subforms. (The hyperlink opens a PDF document.) When I close the pdf document and then click on the [cmdAllReqns] button to release the filter, I get Error #2165 "You can't hide a control that has the focus". The two command buttons still work fine if I don't use the hyperlink. I'm having trouble finding the problem because I can't see which control has the focus. Is there a command I can run in the Immediate window that will identify the control the currently has the focus?
Private Sub cmdEnterJD_Click()
On Error GoTo Err_cmdEnterJD_Click
Me.FilterOn = False
Me.Filter = "[JD]='" & Me![txtEnterJD] & "' AND [Serial] = '" & Me![txtEnterSerial] & "'"
Me.FilterOn = True
If IsNull(Forms![frmReqnWatch]![JD]) Then
MsgBox "That requisition is not in the database." & vbCrLf, _
vbOKOnly, "RPP Tracking System"
Me.FilterOn = False
Me.txtEnterJD = ""
Me.txtEnterSerial = ""
Me.txtEnterJD.SetFocus
Else
Me.txtEnterJD.SetFocus
Me.cmdEnterJD.Visible = False
Me.cmdAllReqns.Visible = True
End If
Exit_cmdEnterJD_Click:
Exit Sub
Err_cmdEnterJD_Click:
Call RPPErrorHandler
Resume Exit_cmdEnterJD_Click
End Sub
Private Sub cmdAllReqns_Click()
On Error GoTo Err_cmdAllReqns_Click
Me.FilterOn = False
Me.Filter = ""
txtEnterJD = ""
txtEnterSerial = ""
Me.txtEnterJD.SetFocus
Me.cmdAllReqns.Visible = False
Me.cmdEnterJD.Visible = True
Exit_cmdAllReqns_Click:
Exit Sub
Err_cmdAllReqns_Click:
Call RPPErrorHandler
Resume Exit_cmdAllReqns_Click
End Sub
Private Sub cmdEnterJD_Click()
On Error GoTo Err_cmdEnterJD_Click
Me.FilterOn = False
Me.Filter = "[JD]='" & Me![txtEnterJD] & "' AND [Serial] = '" & Me![txtEnterSerial] & "'"
Me.FilterOn = True
If IsNull(Forms![frmReqnWatch]![JD]) Then
MsgBox "That requisition is not in the database." & vbCrLf, _
vbOKOnly, "RPP Tracking System"
Me.FilterOn = False
Me.txtEnterJD = ""
Me.txtEnterSerial = ""
Me.txtEnterJD.SetFocus
Else
Me.txtEnterJD.SetFocus
Me.cmdEnterJD.Visible = False
Me.cmdAllReqns.Visible = True
End If
Exit_cmdEnterJD_Click:
Exit Sub
Err_cmdEnterJD_Click:
Call RPPErrorHandler
Resume Exit_cmdEnterJD_Click
End Sub
Private Sub cmdAllReqns_Click()
On Error GoTo Err_cmdAllReqns_Click
Me.FilterOn = False
Me.Filter = ""
txtEnterJD = ""
txtEnterSerial = ""
Me.txtEnterJD.SetFocus
Me.cmdAllReqns.Visible = False
Me.cmdEnterJD.Visible = True
Exit_cmdAllReqns_Click:
Exit Sub
Err_cmdAllReqns_Click:
Call RPPErrorHandler
Resume Exit_cmdAllReqns_Click
End Sub