PC Review


Reply
Thread Tools Rating: Thread Rating: 5 votes, 4.20 average.

Change Text in TextBox with VBA

 
 
=?Utf-8?B?UGF1bCBLcmFlbWVy?=
Guest
Posts: n/a
 
      18th Dec 2006
I have a TextBox on a form. At times, I want my VBA code to copy a string
into this TextBox. So far, the only way I have been able to do this is by
temporarily setting focus to this TextBox. My code looks basically like this:

MyTextBox.SetFocus
MyTextBox.Text = MyStringVariable
MyOtherControl.SetFocus

This works, but my problem is that I don't want this TextBox to be visible
and I do not want it to be a TabStop. Whenever I set the TextBox Visible and
Tabstop properties to "No", my code no longer works. I think this is because
focus can no longer be set to the TextBox.

Is there another way that I can manipulate the text in a TextBox without
setting focus to it? Or, is there a way that I can hide this TextBox from my
users without setting the Visible and Tabstop properties to "No"?

Thanks,
Paul
--
Paul Kraemer
 
Reply With Quote
 
 
 
 
HRE
Guest
Posts: n/a
 
      18th Dec 2006
Try useing MyTextBox.Value = MyStringVariable instead.

Paul Kraemer wrote:
> I have a TextBox on a form. At times, I want my VBA code to copy a string
> into this TextBox. So far, the only way I have been able to do this is by
> temporarily setting focus to this TextBox. My code looks basically like this:
>
> MyTextBox.SetFocus
> MyTextBox.Text = MyStringVariable
> MyOtherControl.SetFocus
>
> This works, but my problem is that I don't want this TextBox to be visible
> and I do not want it to be a TabStop. Whenever I set the TextBox Visible and
> Tabstop properties to "No", my code no longer works. I think this is because
> focus can no longer be set to the TextBox.
>
> Is there another way that I can manipulate the text in a TextBox without
> setting focus to it? Or, is there a way that I can hide this TextBox from my
> users without setting the Visible and Tabstop properties to "No"?
>
> Thanks,
> Paul
> --
> Paul Kraemer


 
Reply With Quote
 
 
 
 
missinglinq via AccessMonster.com
Guest
Posts: n/a
 
      18th Dec 2006
HRE's correct, MyTextBox.Text requires that the control has focus, MyTextBox.
Value doesn't! I use the latter all the time so I don't have to worry about
focus.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...oding/200612/1

 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      18th Dec 2006
Paul Kraemer wrote:

>I have a TextBox on a form. At times, I want my VBA code to copy a string
>into this TextBox. So far, the only way I have been able to do this is by
>temporarily setting focus to this TextBox. My code looks basically like this:
>
>MyTextBox.SetFocus
>MyTextBox.Text = MyStringVariable
>MyOtherControl.SetFocus
>
>This works, but my problem is that I don't want this TextBox to be visible
>and I do not want it to be a TabStop. Whenever I set the TextBox Visible and
>Tabstop properties to "No", my code no longer works. I think this is because
>focus can no longer be set to the TextBox.
>
>Is there another way that I can manipulate the text in a TextBox without
>setting focus to it? Or, is there a way that I can hide this TextBox from my
>users without setting the Visible and Tabstop properties to "No"?



I'll try to explain why you should not use the Text
property. Unlike VB, Access uses the Value property
instead. For Access text and combo box controls, the Text
property is only useful in fairly limited situations because
it contains a user's input at any point until the entered
string is completed (by using Tab, Enter or mouse). When
comitted, the entered text is then evaluated (converted to
binary, trimmed or whatever) and stored in the Value
property.

Note that the Text property doesn't even exist for other
types of controls.

--
Marsh
MVP [MS Access]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change textbox color based on matching value in different textbox CompleteNewb Microsoft Access Form Coding 4 16th Nov 2007 11:41 PM
copy text in textbox to another textbox on click leon Microsoft Access Form Coding 3 30th Mar 2005 04:47 PM
Textbox Bug? Missing/delayed update of textbox filled via VBA =?Utf-8?B?TWFyY00=?= Microsoft Excel Programming 0 4th Nov 2004 06:47 PM
Textbox Bug? Missing/delayed update of textbox filled via VBA =?Utf-8?B?TWFyY00=?= Microsoft Excel Programming 0 4th Nov 2004 06:43 PM
Can I change an unbound textbox into a bound textbox? yma Microsoft Access Forms 1 11th Sep 2003 10:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:19 PM.