SetFocus from subform to mainform

G

Guest

I keep trying to move the focus from a textbox on a subform to the mainform. I want to make the textbox invisible and therefor it needs to lose the focus. With some trial and error I discovered that you need to set the focus first on a control on the subform and then stepwise to the form. However, when the subform contains no records, this first step gives an error (logical), so I left it out again. Now, this is my code:

Me![subFrm_Answers].SetFocus
Me.SetFocus
txtReport.SetFocus
Me![subFrm_Answers].Form![txtAnswerShort].Visible = True
Me![subFrm_Answers].Form![txtAnswerLong].Visible = False

Can anyone help me???
 
P

PC Datasheet

Your post is very confusing!

The code is code that would be in the main form setting the visible property for
two controls in the subform. This is contrary to what your question says.
Logically if there are no records in the subform, there is no need to run the
code.

??????

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com


Maaike said:
I keep trying to move the focus from a textbox on a subform to the mainform. I
want to make the textbox invisible and therefor it needs to lose the focus.
With some trial and error I discovered that you need to set the focus first on a
control on the subform and then stepwise to the form. However, when the subform
contains no records, this first step gives an error (logical), so I left it out
again. Now, this is my code:
Me![subFrm_Answers].SetFocus
Me.SetFocus
txtReport.SetFocus
Me![subFrm_Answers].Form![txtAnswerShort].Visible = True
Me![subFrm_Answers].Form![txtAnswerLong].Visible = False

Can anyone help me???
 

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