LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default TextBox on a UserForm -- AfterUpdate

Fred:

From my first look, it appears that your code is correct. I assume that
the text box in question shows up on the screen and behaves correctly, except
for the responding to the event. Where is the "Sub txtZoom_AfterUpdate()"
code located? It has to be inside of the code module (actually, the form's
class module) so that it can be recognized for the event. If you have it in
a separate module, then Excel can't find it to execute. If it is in the
class module, I'd place a few DEBUG.PRINT or MSGBOX statements in and around
the click event code to make sure that I'm where I want to be. Also, I'd
build a temporary button on the form to "manually" activate (simulate) the
AfterUpdate event just to make sure that everything is working as planned.

Steve in Ohio

"Fred Holmes" wrote:

I'm trying to get the AfterUpdate event to work in a TextBox on a
UserForm. It works fine if the TextBox is created using the Controls
Toolbox and placing the TextBox on the form in the "conventinal"
manner. However, I'm trying to use a TextBox that is created with a
Set statemnt in the UserForm code.

Dim WithEvents txtZoom As MSForms.TextBox

Set txtZoom = Me.Controls.Add("forms.TextBox.1", "txtZoom", True)
With txtZoom
.Visible = True
.Top = 3
.Left = 50
.Height = 18
.Width = 40
.Text = "100"
.TextAlign = fmTextAlignCenter
.BackStyle = fmBackStyleOpaque
.BackColor = &H80000005 ' White
.BorderStyle = fmBorderStyleSingle
.BorderColor = &H80000006 ' black
.SpecialEffect = fmSpecialEffectSunken
.Font.Size = 10
.Font.Bold = True
.EnterFieldBehavior = fmEnterFieldBehaviorSelectAll
.EnterKeyBehavior = False
.HideSelection = True
.SelectionMargin = True
.TabKeyBehavior = False
.IMEMode = fmIMEModeNoControl

End With

Private Sub txtZoom_AfterUpdate() ' AfterUpdate, not Change
' This sholud execute the zoom function by pressing Enter
' This works fine on the Old Form, but not on the New Form
' in which all of the controls are created by Set statements
' in Code. AfterUpdate does not "fire" on the new Form.
Me.Zoom = txtZoom.Text
Me.Height = hf * (txtZoom.Text / 100) ' hf = initial form height
Me.Width = wf * (txtZoom.Text / 100) ' wf = initial form width
End Sub ' Private Sub txtZoom_AfterUpdate()

The properties listed in the code for txtZoom are those taken from the
Properties dialog of the verision in which the controls are created on
the form in the "customary" fashion. I tried to make sure that any
property that looked at all "relevant" was set to an identical value
in both instances.

MS Office 2003, SP-1 WinXP, SP-2

Thanks for any help.

Fred Holmes

 
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
userform textbox Phil Excel Worksheet Functions 5 January 16th 05 06:59 PM
VBA - AfterUpdate TextBox bforster1[_23_] Excel Programming 0 November 5th 04 08:09 PM
Textbox in userform Harald Staff Excel Programming 0 September 8th 04 11:51 AM
Textbox in userform shaharul[_6_] Excel Programming 3 April 15th 04 12:54 PM
UserForm TextBox to ActiveSheet TextBox over 256 characters Dan E[_2_] Excel Programming 1 July 28th 03 07:36 PM


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

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

About Us

"It's about Microsoft Excel"