From: ericb on
Hi,

The same problem again.

On the main ("MainF") form is a subform ("SubF") that displays a datasheet.
When displayed, I want the cursor to be set on the
first record of the datasheet. I hope I'm using the correct terms !

To do so, in the On Open event of the SubF I put the following line :

DoCmd.GoToRecord acDataForm, "SubF", acFirst

and got a message saying the form is not open yet.


I also tried me![SubF].setfocus but that did not do it either.

Would somebody have a suggestion on how to set the cursor on the first
record when I open the subform ?

Thank you.
--
Eric
From: Dirk Goldgar on
"ericb" <eric(a)b.com> wrote in message
news:580277CC-E293-46D8-A44E-551E5FDDE37B(a)microsoft.com...
> Hi,
>
> The same problem again.
>
> On the main ("MainF") form is a subform ("SubF") that displays a
> datasheet.
> When displayed, I want the cursor to be set on the
> first record of the datasheet. I hope I'm using the correct terms !
>
> To do so, in the On Open event of the SubF I put the following line :
>
> DoCmd.GoToRecord acDataForm, "SubF", acFirst
>
> and got a message saying the form is not open yet.
>
>
> I also tried me![SubF].setfocus but that did not do it either.
>
> Would somebody have a suggestion on how to set the cursor on the first
> record when I open the subform ?


How about using the Load event of the main form to set the focus to the
subform, like this:

'------ start of code ------
Private Sub Form_Load()

Me.SubF.SetFocus

End Sub
'------ end of code ------

It seems to me that the subform will be on its first record, having just
been opened, and will again be on its first record after being requeried
when the first record becomes current in the main form, so all you really
need to do is send the focus there.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

From: ericb on
I really don't get it.

I tried that line in the on load event and it does not work.

What I really don't get is if i open or close the navigation pan, the cursor
appears.

Or if I click any place on the main form the cursor then appears.

I don't understand this one, somehow I have to click something for it to
appear.

Would you have another suggestion ?

Thanks.
--
Eric


"Dirk Goldgar" wrote:

> "ericb" <eric(a)b.com> wrote in message
> news:580277CC-E293-46D8-A44E-551E5FDDE37B(a)microsoft.com...
> > Hi,
> >
> > The same problem again.
> >
> > On the main ("MainF") form is a subform ("SubF") that displays a
> > datasheet.
> > When displayed, I want the cursor to be set on the
> > first record of the datasheet. I hope I'm using the correct terms !
> >
> > To do so, in the On Open event of the SubF I put the following line :
> >
> > DoCmd.GoToRecord acDataForm, "SubF", acFirst
> >
> > and got a message saying the form is not open yet.
> >
> >
> > I also tried me![SubF].setfocus but that did not do it either.
> >
> > Would somebody have a suggestion on how to set the cursor on the first
> > record when I open the subform ?
>
>
> How about using the Load event of the main form to set the focus to the
> subform, like this:
>
> '------ start of code ------
> Private Sub Form_Load()
>
> Me.SubF.SetFocus
>
> End Sub
> '------ end of code ------
>
> It seems to me that the subform will be on its first record, having just
> been opened, and will again be on its first record after being requeried
> when the first record becomes current in the main form, so all you really
> need to do is send the focus there.
>
> --
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
>
> (please reply to the newsgroup)
>
From: Dirk Goldgar on
"ericb" <eric(a)b.com> wrote in message
news:296A9AAD-BB99-42C9-83C4-F314E9CFF8D5(a)microsoft.com...
>I really don't get it.
>
> I tried that line in the on load event and it does not work.
>
> What I really don't get is if i open or close the navigation pan, the
> cursor
> appears.
>
> Or if I click any place on the main form the cursor then appears.
>
> I don't understand this one, somehow I have to click something for it to
> appear.
>
> Would you have another suggestion ?


I'm not sure I understand exactly what is happening. I thought your concern
was about where the focus is, but maybe I misunderstood you. When you talk
about the cursor, are you talking about the mouse pointer, or the text-entry
caret, or just the application's focus?

How are you opening the form? Are you opening it by double-clicking in the
nav pane, or by code or macro or what?

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

From: ericb on
My application begins with a login form, once the user identified himself he
is asked to click the login cmd button and then this happens :

Private Sub cmdLogin_Click()

lngSelectedUser = Nz(DLookup("[ID_User]", "[tblUsers]", "[txtPassword] =
'" & Me!txtMotPasse & "'"), 0)

' Test pour voir si le mot de passe est le bon pour cet usager
If lngSelectedUser <> Me!cboUsers.value Then
' Set le focus au Mot de passe
Me!txtMotPasse.SetFocus

' Afficge msg d'erreur
MsgBox GetMsgErreur(err_frmDialogLogin_LoginErreur),
vbCritical, "Login"
lngSelectedUser = 0
Else
' Entre dans le programme
UpdateRibbon
DoCmd.OpenForm "Home Base"
DoCmd.Close acForm, Me.Name, acSaveNo
End If

End Sub


If everything is OK I then open the form "Home Base".

On Home Base is a subform that displays a datasheet.

The cursor I'm talking about is the 'Orange' one that we can move around on
the datasheet with the 4 arrows (Up, Down, left, Right)

It only appears when I click somewhere on the main (Home Base) form. I can't
get it to appear (or show up) right at the beggining when the subform opens.

I hope hope this helps you.

And thank for the effort.

--
Eric


"Dirk Goldgar" wrote:

> "ericb" <eric(a)b.com> wrote in message
> news:296A9AAD-BB99-42C9-83C4-F314E9CFF8D5(a)microsoft.com...
> >I really don't get it.
> >
> > I tried that line in the on load event and it does not work.
> >
> > What I really don't get is if i open or close the navigation pan, the
> > cursor
> > appears.
> >
> > Or if I click any place on the main form the cursor then appears.
> >
> > I don't understand this one, somehow I have to click something for it to
> > appear.
> >
> > Would you have another suggestion ?
>
>
> I'm not sure I understand exactly what is happening. I thought your concern
> was about where the focus is, but maybe I misunderstood you. When you talk
> about the cursor, are you talking about the mouse pointer, or the text-entry
> caret, or just the application's focus?
>
> How are you opening the form? Are you opening it by double-clicking in the
> nav pane, or by code or macro or what?
>
> --
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
>
> (please reply to the newsgroup)
>