Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 8th, 2004, 11:25 AM
Authorized User
 
Join Date: Oct 2003
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Default Previous Control Name

Hi Everyone,

The best way I can explain this is to show an example.

I have a row of textbox controls on an MS-Access form. I then click on a command button on the form. At that point, I need to know what the name of the control was (in this case, which textbox) had the focus before I clicked on the button.

Any ideas would be SUPER helpful!

Thank You All

:)
 
Old November 8th, 2004, 11:57 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   The problem here is that when you click on the button, IT has the focus, so you can't refer to the text box's GotFocus event or status, because it no longer has that status.

   Can you make a button for each text box? That way each button can just refer to its own text box. You could even make them invisible until the text box has a GotFocus, OnChange, AfterUpdate or OnDirty event, I am not sure which one. That would be the thing to do until someone comes up with the answer to this one.

   Another thing you might try is putting a variable on the form somewhere that holds a value from your text boxes such that, when txtBox1 gets the focus, the variable changes to 1, when txtBox2 has the focus, it changes to 2, etc. Then your button could check that value, be referred to the text box that last had the focus, and get the proper data by referral. It may not be a variable, but another hidden text box that has a value placed in it depending on the text box focus, etc.





mmcdonal
 
Old November 8th, 2004, 12:22 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have a look at
Code:
Screen.PreviousControl

Brian Skelton
Braxis Computer Services Ltd.
 
Old November 8th, 2004, 02:03 PM
Authorized User
 
Join Date: Oct 2003
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you VERY much to both of you! :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to look at the previous record in a for-each dep XSLT 6 October 30th, 2006 04:35 PM
How to get previous date? rupen Javascript How-To 1 June 26th, 2006 10:57 PM
Subtracting a value from a previous value Wes Access 8 March 29th, 2006 12:17 PM
Next and Previous buttons. g_vamsi_krish ASP.NET 1.x and 2.0 Application Design 1 January 19th, 2006 11:19 AM
Move Next, Previous, First and Last nvillare Classic ASP Basics 1 August 1st, 2003 04:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.