Set focus

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

Guest

Can someone explain why the following?

This works:
Me!Jobfrm!Invoicefrm.Form!cboTakenBy.BackColor = 15265264

This does not.
Me!Jobfrm!Invoicefrm.SetFocus
Me!Jobfrm!Invoicefrm.Form!cboTakenBy.SetFocus


The difference as I see it is only backcolor and setfocus. What's the magic?
 
redFred said:
Can someone explain why the following?

This works:
Me!Jobfrm!Invoicefrm.Form!cboTakenBy.BackColor = 15265264

This does not.
Me!Jobfrm!Invoicefrm.SetFocus
Me!Jobfrm!Invoicefrm.Form!cboTakenBy.SetFocus

The difference as I see it is only backcolor and setfocus. What's the magic?


Should be ok, but where you have the code is important
because there are events where the focus can't be moved.

Try moving the code to a different event.
 
Thanks Marshall. I have it attached to a command button on my Reservationfrm
( the "Me!" in my code, I subform up from Jobfrm.) The button sets up new
Invoicefrm and I am wanting to open with focus on that control.

Can you help me?
 
There's something funny here. A main form button's Click
event should be ok for changing the focus.

Looking more closely, I think there is something wrong with
the syntax. What is Jobfrm and what is Invoicefrm?

If Me is the main form, Reservationfrm, then it looks like
Jobfrm is a subform on the main form and Invoicefrm is a
subsubform within Jobfrm.

If that's what you have, then I can't explain why the
BackColor works (unless you are using A2K or an earlier
version). In any case, try using:

Me!Jobfrm.SetFocus
Me!Jobfrm.Form!Invoicefrm.SetFocus
Me!Jobfrm.Form!Invoicefrm.Form!cboTakenBy.SetFocus
 
Looks like I was failing to set focus in the correct step-down. Once I set
focus to Jobfrm first, it work as desired.

Thanks so much.

Marshall Barton said:
There's something funny here. A main form button's Click
event should be ok for changing the focus.

Looking more closely, I think there is something wrong with
the syntax. What is Jobfrm and what is Invoicefrm?

If Me is the main form, Reservationfrm, then it looks like
Jobfrm is a subform on the main form and Invoicefrm is a
subsubform within Jobfrm.

If that's what you have, then I can't explain why the
BackColor works (unless you are using A2K or an earlier
version). In any case, try using:

Me!Jobfrm.SetFocus
Me!Jobfrm.Form!Invoicefrm.SetFocus
Me!Jobfrm.Form!Invoicefrm.Form!cboTakenBy.SetFocus
--
Marsh
MVP [MS Access]

Thanks Marshall. I have it attached to a command button on my Reservationfrm
( the "Me!" in my code, I subform up from Jobfrm.) The button sets up new
Invoicefrm and I am wanting to open with focus on that control.
 
Well, yes, that was the specific problem, but I was also
trying to warn you that newer versions of Access require you
to use the .Form property when referring to a control
(including a subform control) on a subform. Omitting the
..Form property as you did has caused a lot of problems when
upgrading to a newer version of Access so it would be
advisable to fix those references now.
 
Back
Top