Advertisement

02.29.2008 at 07:27AM PST, ID: 23203901
[x]
Attachment Details

Set Focus back to main form, from subform, so I can hide the subform?

Asked by dyoung520 in Microsoft Access Database

Tags: MS Access, VBA, RunTime 2165 - "You can't Hide a control that has focus"

Hello,

I know what the error message is I just don't know how to get around it or handle it correctly.  I am using the subform as a type of lookup form for a field in my main form.  If the user clicks a button the subform open and a user can select the correct record to assign.  Long story short if the user clicks in the subform but chooses not to use any of the possible selections and wants to close the subform (hide it) the re click the button and it sets the visible property False again.  However I am getting the following Error:

Run time error 2165  You cant hide a control that has the focus"

I need to set focus else where or something?  I attached my current code for the click event.

Thanks!
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
Private Sub lblLookUpAddress_Click()
 
    Me.Form.SetFocus
    If Me.frm_sub_LookUp_Address.Visible = False Then
        Me.frm_sub_LookUp_Address.Visible = True
    Else
        Me.frm_sub_LookUp_Address.Visible = False
    End If
    
End Sub
[+][-]02.29.2008 at 07:34AM PST, ID: 21014099

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.29.2008 at 07:38AM PST, ID: 21014144

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.29.2008 at 07:40AM PST, ID: 21014175

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.29.2008 at 07:48AM PST, ID: 21014268

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.29.2008 at 07:59AM PST, ID: 21014397

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.29.2008 at 08:00AM PST, ID: 21014406

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Access Database
Tags: MS Access, VBA, RunTime 2165 - "You can't Hide a control that has focus"
Sign Up Now!
Solution Provided By: harfang
Participating Experts: 2
Solution Grade: A
 
 
[+][-]02.29.2008 at 08:00AM PST, ID: 21014411

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.29.2008 at 08:04AM PST, ID: 21014453

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]02.29.2008 at 08:17AM PST, ID: 21014602

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.29.2008 at 08:21AM PST, ID: 21014654

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.29.2008 at 08:24AM PST, ID: 21014685

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.29.2008 at 08:29AM PST, ID: 21014746

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628