Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 07-23-2014, 01:59 PM   #1
musclecarlover07
Newly Registered User
 
Join Date: May 2012
Posts: 236
Thanks: 26
Thanked 0 Times in 0 Posts
musclecarlover07 is on a distinguished road
Set Control back to current field

So I have a control called txtBranch. If the user does not put 1 of 4 options then a msgbox pops up and says that is an invalid option and then gives all the valid options. It then sets the value to blank. Then it moves to the next field. I do not want it to move to the next field. I want it to stay on txtBRanch till it has a correct value. I have tried DoCmd.GoToControl "txtBranch", Me.txtBranch.SetFocus on the OnExit, OnLostFocus, AfterUpdate events and it still continues to go to the next control how do I get it not to go to the next control?

musclecarlover07 is offline   Reply With Quote
Old 07-23-2014, 02:09 PM   #2
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,312
Thanks: 13
Thanked 4,114 Times in 4,046 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Set Control back to current field

I would probably use the before update event of the form:

http://www.baldyweb.com/BeforeUpdate.htm

If you want to catch it as they leave the textbox, you might be able to use the lost focus event but you have to set focus twice if memory serves, first somewhere else then where you really want it.
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
The Following User Says Thank You to pbaldy For This Useful Post:
musclecarlover07 (07-24-2014)
Old 07-23-2014, 02:16 PM   #3
vbaInet
AWF VIP
 
Join Date: Jan 2010
Location: U.K.
Posts: 26,374
Thanks: 0
Thanked 2,423 Times in 2,389 Posts
vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all
Re: Set Control back to current field

Quote:
Originally Posted by pbaldy View Post
I would probably use the before update event of the form:

http://www.baldyweb.com/BeforeUpdate.htm
... just going to add that if you do use what pbaldy suggested, you should be able to set focus to the control in that event.

vbaInet is offline   Reply With Quote
Old 07-23-2014, 02:17 PM   #4
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,312
Thanks: 13
Thanked 4,114 Times in 4,046 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Set Control back to current field

Quote:
Originally Posted by vbaInet View Post
... just going to add that if you do use what pbaldy suggested, you should be able to set focus to the control in that event.
You mean as shown in the link?
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 07-23-2014, 02:20 PM   #5
vbaInet
AWF VIP
 
Join Date: Jan 2010
Location: U.K.
Posts: 26,374
Thanks: 0
Thanked 2,423 Times in 2,389 Posts
vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all
Re: Set Control back to current field

Quote:
Originally Posted by pbaldy View Post
You mean as shown in the link?
Oh
vbaInet is offline   Reply With Quote
Old 07-24-2014, 07:07 AM   #6
musclecarlover07
Newly Registered User
 
Join Date: May 2012
Posts: 236
Thanks: 26
Thanked 0 Times in 0 Posts
musclecarlover07 is on a distinguished road
Re: Set Control back to current field

Awesome that worked almost perfectly. Now it wont set the field to blank. It still leaves the previous value in the field.
musclecarlover07 is offline   Reply With Quote
Old 07-24-2014, 07:33 AM   #7
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,312
Thanks: 13
Thanked 4,114 Times in 4,046 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Set Control back to current field

Have you tried using Undo on the control?

__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
The Following User Says Thank You to pbaldy For This Useful Post:
musclecarlover07 (07-24-2014)
Old 07-24-2014, 07:41 AM   #8
musclecarlover07
Newly Registered User
 
Join Date: May 2012
Posts: 236
Thanks: 26
Thanked 0 Times in 0 Posts
musclecarlover07 is on a distinguished road
Re: Set Control back to current field

THANK YOU. Works beautifully. I didn't even think of the undo action. i have only used that one other time. I never used the BeforeUpdate because I thought that it would validate before you typed. :/ but after looking more into what you said this is exactly what I needed for several other items. Again Thanks pbaldy
musclecarlover07 is offline   Reply With Quote
Old 07-24-2014, 07:54 AM   #9
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,312
Thanks: 13
Thanked 4,114 Times in 4,046 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Set Control back to current field

Happy to help! There are going to be a lot of muscle cars around here in the next week or two. Big car event in the area.
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 08-12-2014, 01:29 PM   #10
musclecarlover07
Newly Registered User
 
Join Date: May 2012
Posts: 236
Thanks: 26
Thanked 0 Times in 0 Posts
musclecarlover07 is on a distinguished road
Re: Set Control back to current field

Ok so I'm back with a similar issue. The undo method worked with text boxes. But its not doing anything with combo boxes. Is there something different for this?

musclecarlover07 is offline   Reply With Quote
Reply

Tags
field , setfocus

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Front and back end in same file produces 'No Current Record' error? Alc Modules & VBA 4 03-28-2012 02:27 PM
Returning back to current record in recordset ssmith001 Modules & VBA 8 05-01-2007 10:49 AM
BACK to current record after Requery ??? accesscomthomas Forms 1 08-08-2004 04:33 PM
BACK to current record after Requery ??? accesscomthomas General 3 08-08-2004 07:37 AM
Go back to current record mark curtis Modules & VBA 1 02-05-2001 12:28 PM




All times are GMT -8. The time now is 07:31 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World