SetFocus from subform to mainform

  • Thread starter Thread starter Guest
  • Start date Start date
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???
 
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???
 
Back
Top