ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   RefEdit in Class Module Problem (https://www.excelbanter.com/excel-programming/365369-refedit-class-module-problem.html)

Mark Driscol[_2_]

RefEdit in Class Module Problem
 
Excel 2002, Windows XP Version 2002, SP1

I have a RefEdit control on a UserForm that has both Change and Exit
events working without a problem. I subsequently defined a Class
module that would contain a RefEdit control and moved the UserForm's
code to the Class module. In the Class module, the Change event code
works without a problem, but the Exit event's code will not work. Even
something as simple as the code below won't work. Any ideas on why
not? One would think that if the Change event code worked, they Exit
event code would work as well.


Public WithEvents RefEdit As RefEdit.RefEdit

Private Sub RefEdit_Exit(ByVal Cancel As MSForms.ReturnBoolean)
MsgBox "Hello"
End Sub


Thanks in advance.

Mark


Mark Driscol[_2_]

RefEdit in Class Module Problem
 
Upon further researching this, it appears that the Exit event doesn't
exist in the Class module for a RefEdit control, although the Change
event does exist. Can anyone explain to me why the Exit event doesn't
exist? Without its existence, I suppose I am left to using the
original code in the UserForm?

Thanks.

Mark


Mark Driscol wrote:
Excel 2002, Windows XP Version 2002, SP1

I have a RefEdit control on a UserForm that has both Change and Exit
events working without a problem. I subsequently defined a Class
module that would contain a RefEdit control and moved the UserForm's
code to the Class module. In the Class module, the Change event code
works without a problem, but the Exit event's code will not work. Even
something as simple as the code below won't work. Any ideas on why
not? One would think that if the Change event code worked, they Exit
event code would work as well.


Public WithEvents RefEdit As RefEdit.RefEdit

Private Sub RefEdit_Exit(ByVal Cancel As MSForms.ReturnBoolean)
MsgBox "Hello"
End Sub


Thanks in advance.

Mark



Mark Driscol[_2_]

RefEdit in Class Module Problem
 
Chip, I see you are online today, can you shed any light on this? Just
wondering if there is a way in advance to tell what Events are/are not
available in a Class module before formulating a solution.

Any input would be appreciated.

Mark


Mark Driscol wrote:
Upon further researching this, it appears that the Exit event doesn't
exist in the Class module for a RefEdit control, although the Change
event does exist. Can anyone explain to me why the Exit event doesn't
exist? Without its existence, I suppose I am left to using the
original code in the UserForm?

Thanks.

Mark


Mark Driscol wrote:
Excel 2002, Windows XP Version 2002, SP1

I have a RefEdit control on a UserForm that has both Change and Exit
events working without a problem. I subsequently defined a Class
module that would contain a RefEdit control and moved the UserForm's
code to the Class module. In the Class module, the Change event code
works without a problem, but the Exit event's code will not work. Even
something as simple as the code below won't work. Any ideas on why
not? One would think that if the Change event code worked, they Exit
event code would work as well.


Public WithEvents RefEdit As RefEdit.RefEdit

Private Sub RefEdit_Exit(ByVal Cancel As MSForms.ReturnBoolean)
MsgBox "Hello"
End Sub


Thanks in advance.

Mark



Chip Pearson

RefEdit in Class Module Problem
 
Some events are available only in the container object of the
control. This applies especially to text boxes, and a RefEdit is
just a juiced up text box. You can use the Exit event in your
form module:

Private Sub RefEdit1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
MsgBox "exit "
End Sub

but the same will not work in a class module containing a
WithEvents RefEdit object.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"Mark Driscol" wrote in message
oups.com...
Chip, I see you are online today, can you shed any light on
this? Just
wondering if there is a way in advance to tell what Events
are/are not
available in a Class module before formulating a solution.

Any input would be appreciated.

Mark


Mark Driscol wrote:
Upon further researching this, it appears that the Exit event
doesn't
exist in the Class module for a RefEdit control, although the
Change
event does exist. Can anyone explain to me why the Exit event
doesn't
exist? Without its existence, I suppose I am left to using
the
original code in the UserForm?

Thanks.

Mark


Mark Driscol wrote:
Excel 2002, Windows XP Version 2002, SP1

I have a RefEdit control on a UserForm that has both Change
and Exit
events working without a problem. I subsequently defined a
Class
module that would contain a RefEdit control and moved the
UserForm's
code to the Class module. In the Class module, the Change
event code
works without a problem, but the Exit event's code will not
work. Even
something as simple as the code below won't work. Any ideas
on why
not? One would think that if the Change event code worked,
they Exit
event code would work as well.


Public WithEvents RefEdit As RefEdit.RefEdit

Private Sub RefEdit_Exit(ByVal Cancel As
MSForms.ReturnBoolean)
MsgBox "Hello"
End Sub


Thanks in advance.

Mark





Mark Driscol[_2_]

RefEdit in Class Module Problem
 
Thank you, Chip, I discovered that after I had debugged the code in my
UserForm, and then ported it all over to my Class module. I just
didn't know if there were ways in advance to tell if an Event existed
in a Class module or not. I could have saved myself the trouble of
porting it over. I have several RefEdits on my UserForm and was trying
to avoid having to have separate Event codes for each one, but it
appears not.

Thanks for responding.

Mark


Chip Pearson wrote:
Some events are available only in the container object of the
control. This applies especially to text boxes, and a RefEdit is
just a juiced up text box. You can use the Exit event in your
form module:

Private Sub RefEdit1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
MsgBox "exit "
End Sub

but the same will not work in a class module containing a
WithEvents RefEdit object.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"Mark Driscol" wrote in message
oups.com...
Chip, I see you are online today, can you shed any light on
this? Just
wondering if there is a way in advance to tell what Events
are/are not
available in a Class module before formulating a solution.

Any input would be appreciated.

Mark


Mark Driscol wrote:
Upon further researching this, it appears that the Exit event
doesn't
exist in the Class module for a RefEdit control, although the
Change
event does exist. Can anyone explain to me why the Exit event
doesn't
exist? Without its existence, I suppose I am left to using
the
original code in the UserForm?

Thanks.

Mark


Mark Driscol wrote:
Excel 2002, Windows XP Version 2002, SP1

I have a RefEdit control on a UserForm that has both Change
and Exit
events working without a problem. I subsequently defined a
Class
module that would contain a RefEdit control and moved the
UserForm's
code to the Class module. In the Class module, the Change
event code
works without a problem, but the Exit event's code will not
work. Even
something as simple as the code below won't work. Any ideas
on why
not? One would think that if the Change event code worked,
they Exit
event code would work as well.


Public WithEvents RefEdit As RefEdit.RefEdit

Private Sub RefEdit_Exit(ByVal Cancel As
MSForms.ReturnBoolean)
MsgBox "Hello"
End Sub


Thanks in advance.

Mark




Chip Pearson

RefEdit in Class Module Problem
 
You can determine all the events supported by an object declared
WithEvents by selecting the variable name in the top left-hand
drop down in the code window. All events supported by that
control will appear in the right-hand drop down. If you select
an event from the right-hand drop down, VBA will insert the
proper Sub statement and an End Sub statement.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Mark Driscol" wrote in message
ups.com...
Thank you, Chip, I discovered that after I had debugged the
code in my
UserForm, and then ported it all over to my Class module. I
just
didn't know if there were ways in advance to tell if an Event
existed
in a Class module or not. I could have saved myself the
trouble of
porting it over. I have several RefEdits on my UserForm and
was trying
to avoid having to have separate Event codes for each one, but
it
appears not.

Thanks for responding.

Mark


Chip Pearson wrote:
Some events are available only in the container object of the
control. This applies especially to text boxes, and a RefEdit
is
just a juiced up text box. You can use the Exit event in your
form module:

Private Sub RefEdit1_Exit(ByVal Cancel As
MSForms.ReturnBoolean)
MsgBox "exit "
End Sub

but the same will not work in a class module containing a
WithEvents RefEdit object.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"Mark Driscol" wrote in message
oups.com...
Chip, I see you are online today, can you shed any light on
this? Just
wondering if there is a way in advance to tell what Events
are/are not
available in a Class module before formulating a solution.

Any input would be appreciated.

Mark


Mark Driscol wrote:
Upon further researching this, it appears that the Exit
event
doesn't
exist in the Class module for a RefEdit control, although
the
Change
event does exist. Can anyone explain to me why the Exit
event
doesn't
exist? Without its existence, I suppose I am left to using
the
original code in the UserForm?

Thanks.

Mark


Mark Driscol wrote:
Excel 2002, Windows XP Version 2002, SP1

I have a RefEdit control on a UserForm that has both
Change
and Exit
events working without a problem. I subsequently defined
a
Class
module that would contain a RefEdit control and moved the
UserForm's
code to the Class module. In the Class module, the
Change
event code
works without a problem, but the Exit event's code will
not
work. Even
something as simple as the code below won't work. Any
ideas
on why
not? One would think that if the Change event code
worked,
they Exit
event code would work as well.


Public WithEvents RefEdit As RefEdit.RefEdit

Private Sub RefEdit_Exit(ByVal Cancel As
MSForms.ReturnBoolean)
MsgBox "Hello"
End Sub


Thanks in advance.

Mark





Mark Driscol[_2_]

RefEdit in Class Module Problem
 
Thanks again, Chip.

Mark



Chip Pearson wrote:
You can determine all the events supported by an object declared
WithEvents by selecting the variable name in the top left-hand
drop down in the code window. All events supported by that
control will appear in the right-hand drop down. If you select
an event from the right-hand drop down, VBA will insert the
proper Sub statement and an End Sub statement.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Mark Driscol" wrote in message
ups.com...
Thank you, Chip, I discovered that after I had debugged the
code in my
UserForm, and then ported it all over to my Class module. I
just
didn't know if there were ways in advance to tell if an Event
existed
in a Class module or not. I could have saved myself the
trouble of
porting it over. I have several RefEdits on my UserForm and
was trying
to avoid having to have separate Event codes for each one, but
it
appears not.

Thanks for responding.

Mark


Chip Pearson wrote:
Some events are available only in the container object of the
control. This applies especially to text boxes, and a RefEdit
is
just a juiced up text box. You can use the Exit event in your
form module:

Private Sub RefEdit1_Exit(ByVal Cancel As
MSForms.ReturnBoolean)
MsgBox "exit "
End Sub

but the same will not work in a class module containing a
WithEvents RefEdit object.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"Mark Driscol" wrote in message
oups.com...
Chip, I see you are online today, can you shed any light on
this? Just
wondering if there is a way in advance to tell what Events
are/are not
available in a Class module before formulating a solution.

Any input would be appreciated.

Mark


Mark Driscol wrote:
Upon further researching this, it appears that the Exit
event
doesn't
exist in the Class module for a RefEdit control, although
the
Change
event does exist. Can anyone explain to me why the Exit
event
doesn't
exist? Without its existence, I suppose I am left to using
the
original code in the UserForm?

Thanks.

Mark


Mark Driscol wrote:
Excel 2002, Windows XP Version 2002, SP1

I have a RefEdit control on a UserForm that has both
Change
and Exit
events working without a problem. I subsequently defined
a
Class
module that would contain a RefEdit control and moved the
UserForm's
code to the Class module. In the Class module, the
Change
event code
works without a problem, but the Exit event's code will
not
work. Even
something as simple as the code below won't work. Any
ideas
on why
not? One would think that if the Change event code
worked,
they Exit
event code would work as well.


Public WithEvents RefEdit As RefEdit.RefEdit

Private Sub RefEdit_Exit(ByVal Cancel As
MSForms.ReturnBoolean)
MsgBox "Hello"
End Sub


Thanks in advance.

Mark





All times are GMT +1. The time now is 05:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com