Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Textbox change event

Hi again

I have set up a user form for users to enter smaple data. The form has
a text box for entering the sample number and I am using various code
to update the data as the sample number is changed using the
textbox.change event. All works well if I stick to stepping one sample
at a time, however if the user wants to enter a sample number and view
the data I run into problems! If the user wants to view say sample 54
and there is no 5 then the code falls over (no erros just reports that
sample 5 does not exist) From what I can gather the change event works
on each key stroke.

I cant find a textbox event to delay or allow multiple key stokes
before acting. Is there anohter way to achive what im tryin to do??

using Excel 2003

Thanks in Advance

Ian
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Textbox change event

Ian,

If you used a combobox instead you could load all the different sample
numbers into it when you open the form. Then they can only pick valid
sample numbers and you could update your data on the Combobox_Change event.
A rough example is below and assumes you have a Userform with "ComboBox1" on
it.

Note that you can add items from a worksheet range or array or other ways
much more efficiently. The Additem code below is just for demonstration:

Private Sub UserForm_Initialize()

With Me.ComboBox1
.AddItem 3
.AddItem 4
.AddItem 5
.AddItem 54
.AddItem 554
.ListIndex = 0 'fills box with first item in list
.MatchEntry = fmMatchEntryFirstLetter 'skips to next item with this
first letter
.MatchRequired = True 'so they can't enter a value not in list
End With

End Sub

Private Sub ComboBox1_Change()

MsgBox "cbox changed"

End Sub

"Ian Mangelsdorf" wrote in message
om...
Hi again

I have set up a user form for users to enter smaple data. The form has
a text box for entering the sample number and I am using various code
to update the data as the sample number is changed using the
textbox.change event. All works well if I stick to stepping one sample
at a time, however if the user wants to enter a sample number and view
the data I run into problems! If the user wants to view say sample 54
and there is no 5 then the code falls over (no erros just reports that
sample 5 does not exist) From what I can gather the change event works
on each key stroke.

I cant find a textbox event to delay or allow multiple key stokes
before acting. Is there anohter way to achive what im tryin to do??

using Excel 2003

Thanks in Advance

Ian



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Textbox change event

A number of ways.

You could try the AfterUpdate or Exit events, although this assumes another
control to move to.

Another way is to use the Keydown event, and trap for enter (KeyCode of 13)
and run your code when that is pressed.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ian Mangelsdorf" wrote in message
om...
Hi again

I have set up a user form for users to enter smaple data. The form has
a text box for entering the sample number and I am using various code
to update the data as the sample number is changed using the
textbox.change event. All works well if I stick to stepping one sample
at a time, however if the user wants to enter a sample number and view
the data I run into problems! If the user wants to view say sample 54
and there is no 5 then the code falls over (no erros just reports that
sample 5 does not exist) From what I can gather the change event works
on each key stroke.

I cant find a textbox event to delay or allow multiple key stokes
before acting. Is there anohter way to achive what im tryin to do??

using Excel 2003

Thanks in Advance

Ian



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Textbox added to Form at runtime too small, can't control size andchange event won't trigger RCGUA Excel Worksheet Functions 2 December 10th 08 09:34 PM
Action Event, CheckBox, Add Row and Textbox Ryan Excel Discussion (Misc queries) 2 July 17th 07 02:32 PM
How can I expose the TextBox BeforeUpdate event to my user class? bereid Excel Discussion (Misc queries) 0 November 30th 05 05:00 PM
MSForms.TextBox Exit event isn't available in Excel class mosule lacos Excel Programming 2 December 12th 03 10:12 AM
event which occurs when a TextBox receives focus Mikhail Excel Programming 2 October 7th 03 02:27 PM


All times are GMT +1. The time now is 05:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"