Results 1 to 4 of 4
  1. #1
    Ultimateneo is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    19

    I am having trouble with setting controls on my subfrm



    Code:
    If Me.cbcompany = True Then
    Me!subfrmbookingin.Form!CompanyName.Visible = True
    ''Me!subfrmbookingin.Form!CompanyName.SetFocus = True (This line does not work)
    Me!subfrmbookingin.Form!FirstName.Visible = False (This line does not work)
    Else
    Me.subfrmbookingin.Form!CompanyName.Visible = False
    Me!subfrmbookingin.Form!FirstName.Visible = True 
    (This line does not work)
    ''Me!subfrmbookingin.Form!FirstName.SetFocus = True
    (This line does not work)
    End If


    I hope someone knows what i am doing wrong here as not sure why it doesnt like multiple commands in the same if.

    Thank you in advance for any help

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    always helps to show code indented

    Code:
    If Me.cbcompany = True Then
        Me!subfrmbookingin.Form!CompanyName.Visible = True
       ''Me!subfrmbookingin.Form!CompanyName.SetFocus = True (This line does not work)
       Me!subfrmbookingin.Form!FirstName.Visible = False (This line does not work)
    Else
       Me.subfrmbookingin.Form!CompanyName.Visible = False
       Me!subfrmbookingin.Form!FirstName.Visible = True 
    (This line does not work)
    ''Me!subfrmbookingin.Form!FirstName.SetFocus = True
    (This line does not work)
    End If
    no reason you cannot use multiple commands

    'doesn't work' doesn't help us to help you. You get an error? if so what?

    also you are only showing part of the code, if you have setwarnings set to false or other error hiding code, you may be masking the problem

  3. #3
    Ultimateneo is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    19

    error message is you cant hide a control that has the focus

    Quote Originally Posted by Ultimateneo View Post
    Code:
    If Me.cbcompany = True Then
    Me!subfrmbookingin.Form!CompanyName.Visible = True
    ''Me!subfrmbookingin.Form!CompanyName.SetFocus = True (This line does not work)
    Me!subfrmbookingin.Form!FirstName.Visible = False (This line does not work)
    Else
    Me.subfrmbookingin.Form!CompanyName.Visible = False
    Me!subfrmbookingin.Form!FirstName.Visible = True 
    (This line does not work)
    ''Me!subfrmbookingin.Form!FirstName.SetFocus = True
    (This line does not work)
    End If


    I hope someone knows what i am doing wrong here as not sure why it doesnt like multiple commands in the same if.

    Thank you in advance for any help
    error message is you cant hide a control that has the focus

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    that error message can only appear for one or both of these lines

    Me.subfrmbookingin.Form!CompanyName.Visible = False
    Me!subfrmbookingin.Form!FirstName.Visible = False

    before hiding the control, you need to move the focus to another control

    try changing the order
    1. make control to receive the focus visible
    2. set the focus to the newly visible control
    3. hide the other control

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 10
    Last Post: 04-14-2017, 08:52 AM
  2. Replies: 8
    Last Post: 02-04-2013, 11:32 AM
  3. Replies: 2
    Last Post: 08-28-2012, 03:43 PM
  4. Replies: 2
    Last Post: 05-29-2012, 12:33 PM
  5. setting values of multiple controls
    By desimoreno in forum Forms
    Replies: 9
    Last Post: 12-14-2011, 02:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums