Main Page | Report this Page
Computers Forum Index  »  Computer - Databases - MS Access  »  Setting Focus to Field after Function call ?...
Page 1 of 1    

Setting Focus to Field after Function call ?...

Author Message
Malcolm Hind...
Posted: Sat Oct 24, 2009 6:14 pm
Guest
I have a Color picker to lookup color numbers to be kept in
fields - I give access to the Color Picker via a button, whn
the user has selected a button I would like to be able to
place him back in the field he came from (the one the color
was chosen for) or the next field in tab order (I have not
decided which is better yet) using code.

I have tried using Screen.PreviousControl.SetFocus but that
ends up with another window being selected - I presume because
I have been in the color picker window ?

I have experimented with saving the field name using
strFieldFocusName = Screen.PreviousControl - then trying to
set focus by using it - strFieldFocusName.SetFocus or
Screen.ActiveControl.Name = strFieldFocusName but these
generate an error about unsupported somethings.

Can someone give me a good way to do this please ?

Thanks
 
Steve...
Posted: Sat Oct 24, 2009 9:31 pm
Guest
Hello Malcolm,

You can put this code in the Click event of your button if your Color Picker
is on a form:

DoCmd.OpenForm "NameOfColorPickerForm",,,,acDialog
Me!NameOfFieldToSetFocusTo
DoCmd.Close "NameOfColorPickerForm"

And ..........
Put this code in the AfterUpdate event of the Color Picker:
Me.Visible = False

Steve
santus at (no spam) penn.com


"Malcolm Hind" <m.hind505 at (no spam) NOSPAMbtinternet.com> wrote in message
news:Xns9CAF9B2ACBBF8MalHind at (no spam) 193.202.122.126...
Quote:
I have a Color picker to lookup color numbers to be kept in
fields - I give access to the Color Picker via a button, whn
the user has selected a button I would like to be able to
place him back in the field he came from (the one the color
was chosen for) or the next field in tab order (I have not
decided which is better yet) using code.

I have tried using Screen.PreviousControl.SetFocus but that
ends up with another window being selected - I presume because
I have been in the color picker window ?

I have experimented with saving the field name using
strFieldFocusName = Screen.PreviousControl - then trying to
set focus by using it - strFieldFocusName.SetFocus or
Screen.ActiveControl.Name = strFieldFocusName but these
generate an error about unsupported somethings.

Can someone give me a good way to do this please ?

Thanks
 
hbinc...
Posted: Sun Oct 25, 2009 11:50 am
Guest
On Oct 24, 3:14 pm, Malcolm Hind <m.hind... at (no spam) NOSPAMbtinternet.com>
wrote:
Quote:
I have a Color picker to lookup color numbers to be kept in
fields - I give access to the Color Picker via a button, whn
the user has selected a button I would like to be able to
place him back in the field he came from (the one the color
was chosen for) or the next field in tab order (I have not
decided which is better yet) using code.

I have tried using Screen.PreviousControl.SetFocus but that
ends up with another window being selected - I presume because
I have been in the color picker window ?

I have experimented with saving the field name using
strFieldFocusName = Screen.PreviousControl - then trying to
set focus by using it - strFieldFocusName.SetFocus or
Screen.ActiveControl.Name = strFieldFocusName but these
generate an error about unsupported somethings.

Can someone give me a good way to do this please ?

Thanks

Hi Malcolm,

I use Screen.PreviousControl.SetFocus all the time, and it works
perfectly.
But, Screen refers to the object that has the focus, and to get
unambiguous results you can better place this command before the
opening of your Color Picker form.

HBInc.
 
Malcolm Hind...
Posted: Fri Oct 30, 2009 4:22 pm
Guest
"Steve" <notmyemail at (no spam) address.com> wrote in
news:6Oqdneyb1uWUp37XnZ2dnUVZ_oWdnZ2d at (no spam) earthlink.com:

Quote:
Hello Malcolm,

You can put this code in the Click event of your button if
your Color
Picker is on a form:

DoCmd.OpenForm "NameOfColorPickerForm",,,,acDialog
Me!NameOfFieldToSetFocusTo
DoCmd.Close "NameOfColorPickerForm"

And ..........
Put this code in the AfterUpdate event of the Color Picker:
Me.Visible = False

Steve
santus at (no spam) penn.com


"Malcolm Hind" <m.hind505 at (no spam) NOSPAMbtinternet.com> wrote in
message
news:Xns9CAF9B2ACBBF8MalHind at (no spam) 193.202.122.126...
I have a Color picker to lookup color numbers to be kept in
fields - I give access to the Color Picker via a button,
whn
the user has selected a button I would like to be able to
place him back in the field he came from (the one the color
was chosen for) or the next field in tab order (I have not
decided which is better yet) using code.

I have tried using Screen.PreviousControl.SetFocus but that
ends up with another window being selected - I presume
because
I have been in the color picker window ?

I have experimented with saving the field name using
strFieldFocusName = Screen.PreviousControl - then trying to
set focus by using it - strFieldFocusName.SetFocus or
Screen.ActiveControl.Name = strFieldFocusName but these
generate an error about unsupported somethings.

Can someone give me a good way to do this please ?

Thanks




Thanks for the reply steve. My call is a function call, like
this:-

tColor = tDialogColor() - tDialogColor is a function contained
in a Module - tColor is a local that recieves the 'picked'
color OR -1 is returned if cancelled.

Thanks
 
Steve...
Posted: Fri Oct 30, 2009 7:04 pm
Guest
How about using this code in the Click event of your button:

tColor = tDialogColor()
Me!NameOfFieldToSetFocusTo.SetFocus

Steve


"Malcolm Hind" <m.hind505 at (no spam) NOSPAMbtinternet.com> wrote in message
news:Xns9CB47DF474BABMalHind at (no spam) 91.208.207.171...
Quote:
"Steve" <notmyemail at (no spam) address.com> wrote in
news:6Oqdneyb1uWUp37XnZ2dnUVZ_oWdnZ2d at (no spam) earthlink.com:

Hello Malcolm,

You can put this code in the Click event of your button if
your Color
Picker is on a form:

DoCmd.OpenForm "NameOfColorPickerForm",,,,acDialog
Me!NameOfFieldToSetFocusTo
DoCmd.Close "NameOfColorPickerForm"

And ..........
Put this code in the AfterUpdate event of the Color Picker:
Me.Visible = False

Steve
santus at (no spam) penn.com


"Malcolm Hind" <m.hind505 at (no spam) NOSPAMbtinternet.com> wrote in
message
news:Xns9CAF9B2ACBBF8MalHind at (no spam) 193.202.122.126...
I have a Color picker to lookup color numbers to be kept in
fields - I give access to the Color Picker via a button,
whn
the user has selected a button I would like to be able to
place him back in the field he came from (the one the color
was chosen for) or the next field in tab order (I have not
decided which is better yet) using code.

I have tried using Screen.PreviousControl.SetFocus but that
ends up with another window being selected - I presume
because
I have been in the color picker window ?

I have experimented with saving the field name using
strFieldFocusName = Screen.PreviousControl - then trying to
set focus by using it - strFieldFocusName.SetFocus or
Screen.ActiveControl.Name = strFieldFocusName but these
generate an error about unsupported somethings.

Can someone give me a good way to do this please ?

Thanks




Thanks for the reply steve. My call is a function call, like
this:-

tColor = tDialogColor() - tDialogColor is a function contained
in a Module - tColor is a local that recieves the 'picked'
color OR -1 is returned if cancelled.

Thanks
 
 
Page 1 of 1    
All times are GMT
The time now is Sun Nov 29, 2009 4:26 pm