Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

2165

Discussion in 'Information Technology' started by Chey, Jul 28, 2006.

  1. Chey

    Chey
    Expand Collapse
    Guest

    I keep getting an error message 2165 You can't hid a control that has the focus

    I have 5 command buttons each have a variation of this
    Private Sub Post_Travel_Click()
    Forms![After Travel]![Post Travel1].Visible = True
    Forms![After Travel]![Cash Only Test].Visible = False
    Forms![After Travel]![Mileage Only 1].Visible = False
    Forms![After Travel]![Other Info].Visible = False
    Forms![After Travel]![Per Travel 0 Layovers].Visible = False

    This works great at first. When I start with the first command button and
    the form is visable, I can type in information then when I for example go to
    the cash only command button to make that for visable I get the error
    message. If I close out and come back in every thing is fine again. It
    seems like I have to do something with the focus but I don't know what.

    Please help.
    Thanks
     
  2. Pieter Wijnen

    Pieter Wijnen
    Expand Collapse
    Guest

    you can't hide the control which has focus
    you need to fix tab order or move to another control first

    Pieter

    "Chey" <Chey@discussions.microsoft.com> wrote in message
    news:2A4D1AD8-5A4B-416F-B7CA-086BC8A007E5@microsoft.com...
    >I keep getting an error message 2165 You can't hid a control that has the
    >focus
    >
    > I have 5 command buttons each have a variation of this
    > Private Sub Post_Travel_Click()
    > Forms![After Travel]![Post Travel1].Visible = True
    > Forms![After Travel]![Cash Only Test].Visible = False
    > Forms![After Travel]![Mileage Only 1].Visible = False
    > Forms![After Travel]![Other Info].Visible = False
    > Forms![After Travel]![Per Travel 0 Layovers].Visible = False
    >
    > This works great at first. When I start with the first command button and
    > the form is visable, I can type in information then when I for example go
    > to
    > the cash only command button to make that for visable I get the error
    > message. If I close out and come back in every thing is fine again. It
    > seems like I have to do something with the focus but I don't know what.
    >
    > Please help.
    > Thanks




    --
    ----------------------------------------
    I am using the free version of SPAMfighter for private users.
    It has removed 4367 spam emails to date.
    Paying users do not have this message in their emails.
    Get the free SPAMfighter here: http://www.spamfighter.com/len
     
  3. UpRider

    UpRider
    Expand Collapse
    Guest

    Chey, create a new textbox on the form and call it txtDummy. Set its
    properties to .01" Height and .01" Width which will make it invisible.
    Change your code to this:
    (You don't need the Forms![After Travel] if the code is in the form's
    module).

    Private Sub Post_Travel_Click()
    [txtDummy].setfocus
    [Post Travel1].Visible = True
    [Cash Only Test].Visible = False
    [Mileage Only 1].Visible = False
    [Other Info].Visible = False
    [Per Travel 0 Layovers].Visible = False

    hth, UpRider

    "Chey" <Chey@discussions.microsoft.com> wrote in message
    news:2A4D1AD8-5A4B-416F-B7CA-086BC8A007E5@microsoft.com...
    >I keep getting an error message 2165 You can't hid a control that has the
    >focus
    >
    > I have 5 command buttons each have a variation of this
    > Private Sub Post_Travel_Click()
    > Forms![After Travel]![Post Travel1].Visible = True
    > Forms![After Travel]![Cash Only Test].Visible = False
    > Forms![After Travel]![Mileage Only 1].Visible = False
    > Forms![After Travel]![Other Info].Visible = False
    > Forms![After Travel]![Per Travel 0 Layovers].Visible = False
    >
    > This works great at first. When I start with the first command button and
    > the form is visable, I can type in information then when I for example go
    > to
    > the cash only command button to make that for visable I get the error
    > message. If I close out and come back in every thing is fine again. It
    > seems like I have to do something with the focus but I don't know what.
    >
    > Please help.
    > Thanks
     

Share This Page