corentint
New Member
- Joined
- Jan 31, 2022
- Messages
- 32
- Office Version
- 365
- Platform
- Windows
I have been programming a user oriented procedure. Lots of validation are done. I use "before_update" on many textboxes that the user fills.
I was almost finished, but one last textbox procedure with before_update is totally blocking my program: it refuses to fire up when the user (me for the moment) fills in a value.
Symptoms:
=============================================================
A few notes:
A lot of my variables are defined at the module level, some are public for the entire project.
MyMsgBox is an ADDin procedures (an enhanced message box). It works fine in all my coding, including this project
The Exit command button is part of a class that enable one procedure for all exit buttons in my Userforms.
The textbox in question is on page 2 of a multipage userform.
Here are the CurRecToDisable.text properties (only those that I changed):
Name = CurRecToDisable
bckColor = &H8000000B&
Font = Tahoma used throughout all projects
ForeColor = &H8000000D&
SpecialEffect = fmSpecialeffectSunken
TextAlign = fmTextAlignCenter
The textbox is enabled, not locked, visible etc...
What I tried:
Changing the name of the textbox = no dice
Erasing the textbox from the userform, erasing the textbox code from the module and saving the file. Then closing the file, shutting down Excel and restarting Excel. Running all other procedures after this: they all owrk fine. Then I recreate the textbox as Textbox100 and rewrote the code from a text file independant of Excel and Vba. Then I tried again. Still not firing up.
I am at witt's end.
Can anybody give me an idea of was I might be doing wrong?
(I know this entire presentation is a bit long, but I do not want to waste anybody's time, so I told all that I have done so far).
Thank you in advance.
I was almost finished, but one last textbox procedure with before_update is totally blocking my program: it refuses to fire up when the user (me for the moment) fills in a value.
Symptoms:
- with a stop on the procedure title line, I can verify that it does not fire up
- Further, it freezes all other actions attempted, the only one being a command button to exit; there is a reaction to this button being pressed: Excel crashes!
- I tried changing the name of the textbox, thinking I might have a bad name. I even used textbox100 as a name for it - no dice (textbox1 to 18 are used, of which several have Before_Update events, all working fine)
- Compiling does not give any error.
VBA Code:
Sub CurRecToDisable_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean) THE EVENT FOR THIS NEVER FIRES UP
'Validating the GL number entered to find the record to be deleted
Dim RecordS As Double
Ck = True
Msg = "Input format must conform: 99999.999, for a total of 9 caracters"
Msg2 = "Other then the dot, all caracters must be numeric"
'Dot and length format?
If Mid(CurRecToDisable.Text, 6, 1) <> "." Or Len(CurRecToDisable.Text) <> 9 Then 'Failed
CurRecToDisable.Text = CurRecToDisable.Text & " ??"
CurRecToDisable.BackColor = &HFF&
Cancel = True
XL.Run "MyMsgBox", Msg, 16, "ENTRY ERROR"
Exit Sub
'Numeric only?
ElseIf Not IsNumeric(Left(CurRecToDisable.Text, 5)) Or Not IsNumeric(Right(CurRecToDisable.Text, 3)) Then 'Failed
CurRecToDisable.Text = CurRecToDisable.Text & " ??"
CurRecToDisable.BackColor = &HFF&
Cancel = True
XL.Run "MyMsgBox", Msg2, 16, "ENTRY ERROR"
Exit Sub
End If
CurRecToDisable.BackColor = &HFFFFFF
RecordS = CDbl(CurRecToDisable.Text)
'In the following Call, variable Ck is for a returned value only
Call GLGLSubFind(RecordS, Ck) 'note this suroutine simply checks that the record exists
If Ck = False Then Exit Sub
RecFound.Visible = True
Call Fillform2 'note this subroutine simply populates all other textboxes on page 2 of the userform
End Sub
=============================================================
A few notes:
A lot of my variables are defined at the module level, some are public for the entire project.
MyMsgBox is an ADDin procedures (an enhanced message box). It works fine in all my coding, including this project
The Exit command button is part of a class that enable one procedure for all exit buttons in my Userforms.
The textbox in question is on page 2 of a multipage userform.
Here are the CurRecToDisable.text properties (only those that I changed):
Name = CurRecToDisable
bckColor = &H8000000B&
Font = Tahoma used throughout all projects
ForeColor = &H8000000D&
SpecialEffect = fmSpecialeffectSunken
TextAlign = fmTextAlignCenter
The textbox is enabled, not locked, visible etc...
What I tried:
Changing the name of the textbox = no dice
Erasing the textbox from the userform, erasing the textbox code from the module and saving the file. Then closing the file, shutting down Excel and restarting Excel. Running all other procedures after this: they all owrk fine. Then I recreate the textbox as Textbox100 and rewrote the code from a text file independant of Excel and Vba. Then I tried again. Still not firing up.
I am at witt's end.
Can anybody give me an idea of was I might be doing wrong?
(I know this entire presentation is a bit long, but I do not want to waste anybody's time, so I told all that I have done so far).
Thank you in advance.