Forms and Subforms Help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am having problems . Please Help. I have an Access 2002 db. One master
form with 2 subforms. If the value in a control = 9 I would like the focus
set to a control in the subform. Sometime it works other times it doesn't. I
keep getting GoToControl is not available.
An example of the code:
If Not IsNull(Me!htDt) Then
DoCmd.GoToControl "subFrmWtBp"
DoCmd.GoToControl "visitNum"
End If
I have also used Me.Active Control with the same results.
Thanks in advance for any and all help.
 
Try using the setfocus method instead of DoCmd.GoToControl:

If Not IsNull(Me!htDt) Then
me.subFrmWtBp.setfocus
me.subFrmWtBp.form.visitNum.setfocus
End If
 
I tried this:
The first time everything appears to be working. The next time I enter a
record with similar conditions I get a message 'Can't move the focus to the
control '
Any other suggestions?


Sandra Daigle said:
Try using the setfocus method instead of DoCmd.GoToControl:

If Not IsNull(Me!htDt) Then
me.subFrmWtBp.setfocus
me.subFrmWtBp.form.visitNum.setfocus
End If



--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I am having problems . Please Help. I have an Access 2002 db. One
master form with 2 subforms. If the value in a control = 9 I would
like the focus set to a control in the subform. Sometime it works
other times it doesn't. I keep getting GoToControl is not available.
An example of the code:
If Not IsNull(Me!htDt) Then
DoCmd.GoToControl "subFrmWtBp"
DoCmd.GoToControl "visitNum"
End If
I have also used Me.Active Control with the same results.
Thanks in advance for any and all help.
 
Is the control always visible? What about the subform? What events are you
using to do this?

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I tried this:
The first time everything appears to be working. The next time I
enter a record with similar conditions I get a message 'Can't move
the focus to the control '
Any other suggestions?


Sandra Daigle said:
Try using the setfocus method instead of DoCmd.GoToControl:

If Not IsNull(Me!htDt) Then
me.subFrmWtBp.setfocus
me.subFrmWtBp.form.visitNum.setfocus
End If



--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I am having problems . Please Help. I have an Access 2002 db. One
master form with 2 subforms. If the value in a control = 9 I would
like the focus set to a control in the subform. Sometime it works
other times it doesn't. I keep getting GoToControl is not available.
An example of the code:
If Not IsNull(Me!htDt) Then
DoCmd.GoToControl "subFrmWtBp"
DoCmd.GoToControl "visitNum"
End If
I have also used Me.Active Control with the same results.
Thanks in advance for any and all help.
 
Control and subfrm are always visible. I am doing this in the onExit event
Thanks
Mary

Sandra Daigle said:
Is the control always visible? What about the subform? What events are you
using to do this?

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I tried this:
The first time everything appears to be working. The next time I
enter a record with similar conditions I get a message 'Can't move
the focus to the control '
Any other suggestions?


Sandra Daigle said:
Try using the setfocus method instead of DoCmd.GoToControl:

If Not IsNull(Me!htDt) Then
me.subFrmWtBp.setfocus
me.subFrmWtBp.form.visitNum.setfocus
End If



--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


mary wrote:
I am having problems . Please Help. I have an Access 2002 db. One
master form with 2 subforms. If the value in a control = 9 I would
like the focus set to a control in the subform. Sometime it works
other times it doesn't. I keep getting GoToControl is not available.
An example of the code:
If Not IsNull(Me!htDt) Then
DoCmd.GoToControl "subFrmWtBp"
DoCmd.GoToControl "visitNum"
End If
I have also used Me.Active Control with the same results.
Thanks in advance for any and all help.
 
I'm not sure what might be happening unless there is another event that is
conflicting (ie a form BeforeUpdate event perhaps?) - try moving the code to
the AfterUpdate event of the control and see what happens.

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Control and subfrm are always visible. I am doing this in the onExit
event Thanks
Mary

Sandra Daigle said:
Is the control always visible? What about the subform? What events
are you using to do this?

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I tried this:
The first time everything appears to be working. The next time I
enter a record with similar conditions I get a message 'Can't move
the focus to the control '
Any other suggestions?


:

Try using the setfocus method instead of DoCmd.GoToControl:

If Not IsNull(Me!htDt) Then
me.subFrmWtBp.setfocus
me.subFrmWtBp.form.visitNum.setfocus
End If



--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


mary wrote:
I am having problems . Please Help. I have an Access 2002 db. One
master form with 2 subforms. If the value in a control = 9 I would
like the focus set to a control in the subform. Sometime it works
other times it doesn't. I keep getting GoToControl is not
available. An example of the code:
If Not IsNull(Me!htDt) Then
DoCmd.GoToControl "subFrmWtBp"
DoCmd.GoToControl "visitNum"
End If
I have also used Me.Active Control with the same results.
Thanks in advance for any and all help.
 

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

Back
Top