Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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
Reply With Quote
  #2 (permalink)  
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
Reply With Quote
  #3 (permalink)  
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:35 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.