2165

G

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
 
P

Pieter Wijnen

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

Pieter

Chey said:
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



--
 
U

UpRider

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top