dbTalk Databases Forums  

How to force the cursor to a field

comp.databases.ms-access comp.databases.ms-access


Discuss How to force the cursor to a field in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
 
Posts: n/a

Default How to force the cursor to a field - 11-19-2010 , 02:28 AM






Dear reader,

I need to position the cursor to a field, I use all the codes below but no
one of them moves the cursor to the specified field:

Me.FieldName.SetFocus
Forms.FormName.FielName.SetFocus
DoCmd.GoToControl (“FieldName”)

What is the correct code to move the cursor to a field?
Thanks for any help.

Kind regards,
Simon

Reply With Quote
  #2  
Old   
chrisdev
 
Posts: n/a

Default Re: How to force the cursor to a field - 11-19-2010 , 05:39 AM






Hi Simon,

do you exit the sub, function after the SETFOCUS property or the
DOCMD.CancelEvent in case event can be cancelled?

This is what I use:

fld_PDst_name.SetFocus
DoCmd.CancelEvent
Exit Sub

Chris

Reply With Quote
  #3  
Old   
Salad
 
Posts: n/a

Default Re: How to force the cursor to a field - 11-19-2010 , 09:22 AM



svanbeeknl (AT) hotmail (DOT) com wrote:

Quote:
Dear reader,

I need to position the cursor to a field, I use all the codes below but
no one of them moves the cursor to the specified field:

Me.FieldName.SetFocus
Forms.FormName.FielName.SetFocus
DoCmd.GoToControl (“FieldName”)

What is the correct code to move the cursor to a field?
Thanks for any help.

Kind regards,
Simon
I use Me.FieldName.SetFocus. Howerver, if that is not working for you I
might consider putting the word
STOP
prior that line and step thru your code and see what is happening.

Reply With Quote
  #4  
Old   
Phil
 
Posts: n/a

Default Re: How to force the cursor to a field - 11-19-2010 , 04:25 PM



On 19/11/2010 08:28:10, wrote:
Quote:
Dear reader,

I need to position the cursor to a field, I use all the codes below but no
one of them moves the cursor to the specified field:

Me.FieldName.SetFocus
Forms.FormName.FielName.SetFocus
DoCmd.GoToControl (“FieldName”)

What is the correct code to move the cursor to a field?
Thanks for any help.

Kind regards,
Simon


When do you want to move the focus?
Possibilities that come to mind are
AfterUpdate of a field
OnCurrent of a record - when you first open that record
If the field is on the same form as we are talking about then
MyField.SetFocus should work or you can just set the Tab order

If you want to go to a subform then
Me.SubformName.form!MyField.SetFocus

If you want to go from a sunform to the parent try
Me.Parent!MyField.SetFocus

If you ar doing it out of the blue then use
Forms!MyForm!MyField.SetFocus or
Forms!MyForm!MySubform.Form!MyField.SetFocus

Phil

Reply With Quote
  #5  
Old   
Barry Edmund Wright
 
Posts: n/a

Default Re: How to force the cursor to a field - 11-21-2010 , 01:57 PM



On Nov 19, 3:28*am, <svanbee... (AT) hotmail (DOT) com> wrote:

Hi Simon,

One thing not mentioned in the other responses; remenber that the
field "name" property is not the same as the "Conrol Source" property.
So if your Field Name is called "Last Name" and your "Control Source"
is called strLName you must set focus to me.[Last Name].setfocus not
me.strLName.setfocus

Cheers,
Barry



Quote:
Dear reader,

I need to position the cursor to a field, I use all the codes below but no
one of them moves the cursor to the specified field:

Me.FieldName.SetFocus
Forms.FormName.FielName.SetFocus
DoCmd.GoToControl (FieldName)

What is the correct code to move the cursor to a field?
Thanks for any help.

Kind regards,
Simon

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.