Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
| Search | Today's Posts | Mark Forums Read
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 April 14th, 2006, 02:18 PM
Registered User
 
Join Date: Apr 2006
Location: Memphis, TN, USA.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Select a field on a form, based on variable

I have a form, that has quite a few diffent text fields on it. They are all named very similar, (like txtC1, txtC2, txtM1, txtM2, etc)

What I'm wanting to do, is be able to select a certain field on this form, based on a field name that I am stringing together from criteria that is being built.

So, instead of doing the following...

Me.txtC1.SetFocus

I would like to substitute that for some like

Me.strField.SetFocus
where strField is being defined in a previous line of code.

My question is, how do I go about selecting that field like that?

John
 
Old April 14th, 2006, 02:24 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Try something like this...

Where strControl is the name of the control that you want to set focus on.

Me.Controls(strControl).SetFocus

Hope that helps,

Mike

Mike
EchoVue.com
 
Old April 17th, 2006, 11:16 AM
Registered User
 
Join Date: Apr 2006
Location: Memphis, TN, USA.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It does, thank you very much

John




Similar Threads
Thread Thread Starter Forum Replies Last Post
Fill field based on another field skwilliams Classic ASP Basics 3 December 30th, 2006 11:02 AM
Updating a Date field based on another field arholly Access VBA 6 November 22nd, 2006 11:19 AM
A form field list populating based on another fiel ebburks Access 2 June 3rd, 2006 09:37 AM
Hide Tabs in a Form Based on a field. snoopy92211 Access VBA 1 November 18th, 2004 02:33 PM
Update city field based on zip field nganb SQL Server ASP 0 April 22nd, 2004 10:30 PM





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