set focus

G

Guest

I've look for an answer, tried many things and cannot get this to work. What
am I not seeing? Is there problem with this code? It returns the message
can't hide a control that has focus.

Fails on this statement:
Forms![frm1 Client].Form![Jobfrm].Form![BCAddfrm].Visible = False

Am I not resetting focus away from that?

Here's the routine complete:

Private Sub btnPost_Click()
Forms![frm1 Client].Form!HoldFocus.SetFocus
Forms![frm1 Client].Form![Jobfrm].Form![BCfrm].Visible = True
Forms![frm1 Client].Form![Jobfrm].Form![BCAddfrm].Visible = False
Forms![frm1 Client].Form![Jobfrm].Form![BCExcfrm].Visible = False
Forms![frm1 Client].Form![Jobfrm].Form![BBfrm].Visible = False
Forms![frm1 Client].Form![Jobfrm].Form![HSfrm].Visible = False
Forms![frm1 Client].Form![Jobfrm].Form![POfrm].Visible = False
Forms![frm1 Client].Form![Jobfrm].Form![DCfrm].Visible = False
Forms![frm1 Client].Form![Jobfrm].Form![OSfrm].Visible = False
End Sub

All I am attempting to do is make BCAddfrm INvisible and BCfrm visible again.

Argh! Please help this amateur.
 
G

Guest

Chris, I just had the same problem. I fixed it by putting a text box on my
form called txtFocus. In the click event of your button make the first line
be me.txtFocus.setfocus. This will make the text box have the focus so you
can hide your other controls. The experts may have a better solution, but
this worked for me. Make your text box back color the same as your form them
make its height something like .0007.
 
G

Guest

Thanks, Greg.

I knew of that "trick". Mine is [holdFocus] and has zero dimensions.

Your response reminded me it, too, must be visible to receive focus. Duh!
It was set to invisible. Problem solved.
--
Thanks a bunch,
Chris


Greg Snidow said:
Chris, I just had the same problem. I fixed it by putting a text box on my
form called txtFocus. In the click event of your button make the first line
be me.txtFocus.setfocus. This will make the text box have the focus so you
can hide your other controls. The experts may have a better solution, but
this worked for me. Make your text box back color the same as your form them
make its height something like .0007.

Chris said:
I've look for an answer, tried many things and cannot get this to work. What
am I not seeing? Is there problem with this code? It returns the message
can't hide a control that has focus.

Fails on this statement:
Forms![frm1 Client].Form![Jobfrm].Form![BCAddfrm].Visible = False

Am I not resetting focus away from that?

Here's the routine complete:

Private Sub btnPost_Click()
Forms![frm1 Client].Form!HoldFocus.SetFocus
Forms![frm1 Client].Form![Jobfrm].Form![BCfrm].Visible = True
Forms![frm1 Client].Form![Jobfrm].Form![BCAddfrm].Visible = False
Forms![frm1 Client].Form![Jobfrm].Form![BCExcfrm].Visible = False
Forms![frm1 Client].Form![Jobfrm].Form![BBfrm].Visible = False
Forms![frm1 Client].Form![Jobfrm].Form![HSfrm].Visible = False
Forms![frm1 Client].Form![Jobfrm].Form![POfrm].Visible = False
Forms![frm1 Client].Form![Jobfrm].Form![DCfrm].Visible = False
Forms![frm1 Client].Form![Jobfrm].Form![OSfrm].Visible = False
End Sub

All I am attempting to do is make BCAddfrm INvisible and BCfrm visible again.

Argh! Please help this amateur.
 

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

Top