Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Visual Basic for Applications

Post new topic   Reply to topic
field name as a variable
View previous topic :: View next topic  
Author Message
SKP
Newbie


Joined: 23 Dec 2003
Posts: 7

PostPosted: Dec 30th, 2003 10:04 AM    Post subject: field name as a variable Reply with quote

Is there a way to pass a fieldname as a variable to a procedure? I want to be able to set the focus of a particular field name for different forms based on which command button is being pressed. What would be the declaration type?
Back to top
View user's profile Send private message
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Dec 30th, 2003 01:17 PM    Post subject: Reply with quote

maybe this will help

Code:
FormName.FieldName.Setfocus = True


Just replace the FormName with your formname and FiledName with your fieldname. Hope this helps!
_________________
Code Snippets, Tutorials, Utilities, Controls

Low cost Web Hosting
Hosting starts at as low as $4 per year!


Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags!
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
SKP
Newbie


Joined: 23 Dec 2003
Posts: 7

PostPosted: Dec 30th, 2003 02:33 PM    Post subject: Reply with quote

I'm kinda trying to do that already. The problem that I'm having though is that I'm passing the field name that I want to set focus to as a string argument (I'm not sure if that's how I should be passing it). I get an error saying that "Microsoft Access can't find the field 'strcurFld' referred to in your expression" because it doesn't seem to be taking the actual string from it. Here's the line where I get that error:

Me!stcurFld.SetFocus

Maybe you can tell me what I'm doing wrong here? I'm trying to learn this as I go.

Thanks so much!
Back to top
View user's profile Send private message
Andir
Centurion


Joined: 21 Dec 2003
Posts: 184
Location: Chicago Area

PostPosted: Jan 1st, 2004 03:47 AM    Post subject: Reply with quote

The control name is 'strcurFld'? or what is displayed in the field? If your under the thought that just because your control name begins with a 'str' that it's a string, then change the thought process Smile It's just a name.
I might be wrong, but try using a period '.' instead of the exclamation '!' or removing the Me! all together. You shouldnt need to reference a control on the same form by calling the 'Me' object.
You would just use: strcurFld.SetFocus
_________________
If you happen to see little people sitting on your desk...don't tell anyone or they might think your crazy too.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Visual Basic for Applications All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic