PC Review


Reply
Thread Tools Rate Thread

In a Control: Type some text, then hit a hotkey to append more text (?)

 
 
croy
Guest
Posts: n/a
 
      14th Sep 2010
In a text control on a form, I'd like to be able to type
some text, and then be able to hit a hotkey (before leaving
or saving the field), and have the hotkey append some
"canned" text in front of the text already typed. The
canned text is something that would be occasionally added,
and when it is added, would always be the same.

I've tried using OldValue, but it doesn't seem like the text
entered manually has become OldValue until the focus leaves
the control--true?

I could tell the users to hit the hotkey first, then add
their additional text, but that's not quite as forgiving for
the user.

Any ideas appreciated.

--
croy
 
Reply With Quote
 
 
 
 
Michael J. Strickland
Guest
Posts: n/a
 
      14th Sep 2010

"croy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In a text control on a form, I'd like to be able to type
> some text, and then be able to hit a hotkey (before leaving
> or saving the field), and have the hotkey append some
> "canned" text in front of the text already typed. The
> canned text is something that would be occasionally added,
> and when it is added, would always be the same.
>
> I've tried using OldValue, but it doesn't seem like the text
> entered manually has become OldValue until the focus leaves
> the control--true?
>
> I could tell the users to hit the hotkey first, then add
> their additional text, but that's not quite as forgiving for
> the user.
>
> Any ideas appreciated.
>
> --
> croy


You might try something like this in the KeyDown event (of TextBox1 for
example)to intercept a hotkey (Ctl-h, in this case) and insert the text.

Private Sub txtTextBox1_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = Asc("H") And (Shift And acCtrlMask) > 0 Then
KeyCode = 0
txtTextBox1.Text = "Prefix-" & txtTextBox1.Text
End If

End Sub

--
Mike

-----------------------------------------------------------------------
Michael J. Strickland
Quality Services (E-Mail Removed)
703-560-7380
-----------------------------------------------------------------------



--- news://freenews.netfront.net/ - complaints: (E-Mail Removed) ---
 
Reply With Quote
 
croy
Guest
Posts: n/a
 
      14th Sep 2010
On Tue, 14 Sep 2010 10:55:23 -0400, "Michael J. Strickland"
<(E-Mail Removed)> wrote:

>
>"croy" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>> In a text control on a form, I'd like to be able to type
>> some text, and then be able to hit a hotkey (before leaving
>> or saving the field), and have the hotkey append some
>> "canned" text in front of the text already typed. The
>> canned text is something that would be occasionally added,
>> and when it is added, would always be the same.
>>
>> I've tried using OldValue, but it doesn't seem like the text
>> entered manually has become OldValue until the focus leaves
>> the control--true?
>>
>> I could tell the users to hit the hotkey first, then add
>> their additional text, but that's not quite as forgiving for
>> the user.
>>
>> Any ideas appreciated.



>You might try something like this in the KeyDown event (of TextBox1 for
>example)to intercept a hotkey (Ctl-h, in this case) and insert the text.
>
>Private Sub txtTextBox1_KeyDown(KeyCode As Integer, Shift As Integer)
>
> If KeyCode = Asc("H") And (Shift And acCtrlMask) > 0 Then
> KeyCode = 0
> txtTextBox1.Text = "Prefix-" & txtTextBox1.Text
> End If
>
>End Sub


Thanks--that looks interesting. I *think* I understand
it...

--
croy
 
Reply With Quote
 
croy
Guest
Posts: n/a
 
      14th Sep 2010
On Tue, 14 Sep 2010 10:55:23 -0400, "Michael J. Strickland"
<(E-Mail Removed)> wrote:

>
>"croy" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>> In a text control on a form, I'd like to be able to type
>> some text, and then be able to hit a hotkey (before leaving
>> or saving the field), and have the hotkey append some
>> "canned" text in front of the text already typed. The
>> canned text is something that would be occasionally added,
>> and when it is added, would always be the same.
>>
>> I've tried using OldValue, but it doesn't seem like the text
>> entered manually has become OldValue until the focus leaves
>> the control--true?
>>
>> I could tell the users to hit the hotkey first, then add
>> their additional text, but that's not quite as forgiving for
>> the user.
>>
>> Any ideas appreciated.
>>
>> --
>> croy

>
>You might try something like this in the KeyDown event (of TextBox1 for
>example)to intercept a hotkey (Ctl-h, in this case) and insert the text.
>
>Private Sub txtTextBox1_KeyDown(KeyCode As Integer, Shift As Integer)
>
> If KeyCode = Asc("H") And (Shift And acCtrlMask) > 0 Then
> KeyCode = 0
> txtTextBox1.Text = "Prefix-" & txtTextBox1.Text
> End If
>
>End Sub


Like a charm! Thanks again.

--
croy
 
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
why can't i type in plain text control boxes? Fiona Microsoft Word Document Management 2 21st Jan 2010 01:11 PM
Append Data Type Text Y/N to Data Type Y/N in Query HELP! =?Utf-8?B?dHJveQ==?= Microsoft Access Queries 1 25th Apr 2006 01:11 AM
How to append text to the beginning of the text file Peter Afonin Microsoft Access ADP SQL Server 6 18th Aug 2004 02:41 AM
How to append text to the beginning of the text file Peter Afonin Microsoft Access External Data 6 18th Aug 2004 02:41 AM
How to append text to the beginning of the text file Peter Afonin Microsoft Access 6 18th Aug 2004 02:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:54 AM.