Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default AfterUpdate Event not Running

Hi There,
I have a userform called frmThree which has a bunch of textboxes on it, when
I run the userform the AfterUpdate Event runs fine when I hit enter on each
textbox when I run it as a stand alone userform (from the Visual Basic
Editor). When I try to run the program as it is mean't... the AfterUpdate
Event doesn't Fire.
My program first opens frmOne, from this I click on a button to sign in,
this brings up frmPassword,I enter the code the frmPassword userform
hides... and shows frmTwo... on frmTwo is a commandbutton that shows
frmThree.
Now when I enter a number in the textbox on frmThree the AfterUpdate doesn't
fire thus not formatting my number in the textbox. At this point frmOne,
frmTwo and frmThree would all be in the .show mode.

Anyone no why, this is happening?


Craig


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default AfterUpdate Event not Running

Craig

A shot in the dark, what is the afterupdate code and where is it asigned?

"Craig" wrote:

Hi There,
I have a userform called frmThree which has a bunch of textboxes on it, when
I run the userform the AfterUpdate Event runs fine when I hit enter on each
textbox when I run it as a stand alone userform (from the Visual Basic
Editor). When I try to run the program as it is mean't... the AfterUpdate
Event doesn't Fire.
My program first opens frmOne, from this I click on a button to sign in,
this brings up frmPassword,I enter the code the frmPassword userform
hides... and shows frmTwo... on frmTwo is a commandbutton that shows
frmThree.
Now when I enter a number in the textbox on frmThree the AfterUpdate doesn't
fire thus not formatting my number in the textbox. At this point frmOne,
frmTwo and frmThree would all be in the .show mode.

Anyone no why, this is happening?


Craig



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default AfterUpdate Event not Running

'This code is all within the frmThree Userform
Private Sub TextBox2_AfterUpdate()
Call Update_Inventory(2)
End Sub
Private Sub TextBox3_AfterUpdate()
Call Update_Inventory(3)
End Sub

Public Sub Update_Inventory(TBox As Integer)
Dim iPass as Integer
If TBox <= 20 Then iPass = TBox + 171
If TBox = 20 Then iPass = TBox + 151
frmThree.Controls("TextBox" & TBox).Text =
Format(frmThree.Controls("TextBox" & TBox).Text, "Currency")
If TBox <= 20 Then SpecialCount.Cells(iPass, 14).Value =
Format(frmThree.Controls("TextBox" & TBox).Text, "Currency")
If TBox = 21 Then SpecialCount.Cells(iPass, 26).Value =
Format(frmThree.Controls("TextBox" & TBox).Text, "Currency")
frmThree.TextBox116.Text = Format(SpecialCount.Range("Z190").Value,
"Currency")
End Sub

This code runs fine if I only run the frmThree Userfrom, it doesn't when
opened through other Userforms.
Thanks Craig





"Martin Fishlock" wrote in
message ...
Craig

A shot in the dark, what is the afterupdate code and where is it asigned?

"Craig" wrote:

Hi There,
I have a userform called frmThree which has a bunch of textboxes on it,
when
I run the userform the AfterUpdate Event runs fine when I hit enter on
each
textbox when I run it as a stand alone userform (from the Visual Basic
Editor). When I try to run the program as it is mean't... the AfterUpdate
Event doesn't Fire.
My program first opens frmOne, from this I click on a button to sign in,
this brings up frmPassword,I enter the code the frmPassword userform
hides... and shows frmTwo... on frmTwo is a commandbutton that shows
frmThree.
Now when I enter a number in the textbox on frmThree the AfterUpdate
doesn't
fire thus not formatting my number in the textbox. At this point frmOne,
frmTwo and frmThree would all be in the .show mode.

Anyone no why, this is happening?


Craig





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default AfterUpdate Event not Running


Hello Craig,

I suspect you may have ambigious text box names. It isn't clear from
your post if you are calling Update_Inventory from the other forms.

I have cleaned your code up and added a restriction to it. If the text
box isn't on frmThree then exit the routine. Look this over and let men
know if I have understood you correctly or not.

CALLING THE SUB:
Update_Inventory (TextBox3)

UPDATED CODE:

Code:
--------------------

Sub Update_Inventory(ByRef TB As MSForms.TextBox)

Dim frmName As String
Dim tbName As String
Dim tbNumber As Integer

'Get the Name of the Form the TextBox is on
frmName = TB.Parent.Name

'Is TextBox on frmThree?
If frmName < "frmThree" Then Exit Sub

'Get the TextBox Name
tbName = TB.Name

'Extract the TextBox Number
tbNumber = Val(Mid(tbName, 8, Len(tbName) - 7))

If tbNumber <= 20 Then iPass = tbNumber + 171
If tbNumber = 21 Then iPass = tbNumber + 151

'Format the TextBox Text as Currency
TB.Text = Format(TB.Text, "Currency")

If tbNumber <= 20 Then SpecialCount.Cells(iPass, 14).Value = TB.Text
If tbNumber = 21 Then SpecialCount.Cells(iPass, 26).Value = TB.Text

TextBox116.Text = Format(SpecialCount.Range("Z190").Value, "Currency")

End Sub

--------------------

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=482515

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default AfterUpdate Event not Running

Leith, thanks for the code;
notices the use of

'Get the Name of the Form the TextBox is on
frmName = TB.Parent.Name

Is this sort of line available generically to any Userform.?

I went into a Userform (VBE) and selected a textbox
txtVenName and in the immediate window did:

? txtVenName.Parent.Name << expexting to get frmTest
but instead get r/t error 424 - Object required.

Can you clarify
Thanks,
Jim


"Leith Ross" wrote
in message ...

Hello Craig,

I suspect you may have ambigious text box names. It isn't clear from
your post if you are calling Update_Inventory from the other forms.

I have cleaned your code up and added a restriction to it. If the text
box isn't on frmThree then exit the routine. Look this over and let men
know if I have understood you correctly or not.

CALLING THE SUB:
Update_Inventory (TextBox3)

UPDATED CODE:

Code:
--------------------

Sub Update_Inventory(ByRef TB As MSForms.TextBox)

Dim frmName As String
Dim tbName As String
Dim tbNumber As Integer

'Get the Name of the Form the TextBox is on
frmName = TB.Parent.Name

'Is TextBox on frmThree?
If frmName < "frmThree" Then Exit Sub

'Get the TextBox Name
tbName = TB.Name

'Extract the TextBox Number
tbNumber = Val(Mid(tbName, 8, Len(tbName) - 7))

If tbNumber <= 20 Then iPass = tbNumber + 171
If tbNumber = 21 Then iPass = tbNumber + 151

'Format the TextBox Text as Currency
TB.Text = Format(TB.Text, "Currency")

If tbNumber <= 20 Then SpecialCount.Cells(iPass, 14).Value = TB.Text
If tbNumber = 21 Then SpecialCount.Cells(iPass, 26).Value = TB.Text

TextBox116.Text = Format(SpecialCount.Range("Z190").Value, "Currency")

End Sub

--------------------

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile:
http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=482515





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default AfterUpdate Event not Running

txtVenName isn't an object until the userform is loaded.

You can do that by refering to it. so in the immediate window:

? userform1.TextBox1.Parent.Name
UserForm1

In Leith's code, the userform was already loaded.

--
Regards,
Tom Ogilvy




"Jim May" wrote in message
news:aVmbf.9844$wC.5364@dukeread06...
Leith, thanks for the code;
notices the use of

'Get the Name of the Form the TextBox is on
frmName = TB.Parent.Name

Is this sort of line available generically to any Userform.?

I went into a Userform (VBE) and selected a textbox
txtVenName and in the immediate window did:

? txtVenName.Parent.Name << expexting to get frmTest
but instead get r/t error 424 - Object required.

Can you clarify
Thanks,
Jim


"Leith Ross"

wrote
in message ...

Hello Craig,

I suspect you may have ambigious text box names. It isn't clear from
your post if you are calling Update_Inventory from the other forms.

I have cleaned your code up and added a restriction to it. If the text
box isn't on frmThree then exit the routine. Look this over and let men
know if I have understood you correctly or not.

CALLING THE SUB:
Update_Inventory (TextBox3)

UPDATED CODE:

Code:
--------------------

Sub Update_Inventory(ByRef TB As MSForms.TextBox)

Dim frmName As String
Dim tbName As String
Dim tbNumber As Integer

'Get the Name of the Form the TextBox is on
frmName = TB.Parent.Name

'Is TextBox on frmThree?
If frmName < "frmThree" Then Exit Sub

'Get the TextBox Name
tbName = TB.Name

'Extract the TextBox Number
tbNumber = Val(Mid(tbName, 8, Len(tbName) - 7))

If tbNumber <= 20 Then iPass = tbNumber + 171
If tbNumber = 21 Then iPass = tbNumber + 151

'Format the TextBox Text as Currency
TB.Text = Format(TB.Text, "Currency")

If tbNumber <= 20 Then SpecialCount.Cells(iPass, 14).Value = TB.Text
If tbNumber = 21 Then SpecialCount.Cells(iPass, 26).Value = TB.Text

TextBox116.Text = Format(SpecialCount.Range("Z190").Value, "Currency")

End Sub

--------------------

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile:
http://www.excelforum.com/member.php...o&userid=18465
View this thread:

http://www.excelforum.com/showthread...hreadid=482515





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
Workbook_BeforeClose change event not running correctly Peter Rooney Excel Programming 4 August 5th 05 04:26 PM
AfterUpdate bforster1[_26_] Excel Programming 1 November 6th 04 07:16 PM
VBA - AfterUpdate TextBox bforster1[_23_] Excel Programming 0 November 5th 04 08:09 PM
Running Event Procedure When Cell Updated on Excel Worksheet Tom Ogilvy Excel Programming 0 August 19th 04 03:38 PM
Running command button click event code Marishah Warren Excel Programming 1 December 31st 03 07:53 AM


All times are GMT +1. The time now is 03:33 PM.

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"