[Class] WithEvents level

  • Thread starter Thread starter ALESSANDRO Baraldi
  • Start date Start date
A

ALESSANDRO Baraldi

Hi all.

I try to build a Class sistem to validate the control
on a PrincipalForm/SubForm/SubSubForm

Development:

1 clsControls as CollectionClass
1 clsTextBox
1 clsCombo
1 clsListBox

On a clsControls(collectionClass) i build a recursive
function like this:

' ObjectClass Declarations
Private m_Form As Access.Form ' The Form containing the
controls
Private colControls As New Collection ' Collection for control
classes
Private cTBox As clsTextBox ' TextBox class
Private cCbo As clsComboBox ' Combo class
Private cLbo As clsListBox ' ListBox class

Private Function Create(frm As Access.Form)

Dim ctl As Access.Control

For Each ctl In frm.Controls
If ctl.Tag = m_TAG Then
Select Case ctl.ControlType

Case acTextBox
Set cTBox = New clsTextBox
cTBox.SetTarget ctl
colControls.Add cTBox
Set cTBox = Nothing

Case acComboBox
Set cCbo = New clsComboBox
cCbo.SetTarget ctl
colControls.Add cCbo
Set cCbo = Nothing

Case acListBox
Set cLbo = New clsListBox
cLbo.SetTarget ctl
colControls.Add cLbo
Set cLbo = Nothing

Case acSubform
Create ctl.Form

End Select
End If
Next ctl

End Function

On clsTextBox/comboBox/ListBox i have a Function "SetTarget"
wich generate Control_BeforeUpdate = "[Event Procedure]"
and inside Class i put a MSGBOX(for now on Before Update to check it)

If i have Form/SubForm only all work very good, all my Events are detected
in every two Forms and in every controlType.

If i add the 3° level SUbSubForm, the recoursive Function add correctly the
news 3° Level Controls on Collection, to check it i cycle trought it and all
OK,
but no Events are detected for the 3° Level SubSubForm Controls

What could made this problem ...?
It's Normal one or i made some mistake...?

Thanks for help
 
I find the problem, but is strange one.

If the SubSubForm!Controls Have alrady the Events(BeforeUpdate)
on the Module don't work.

I thought that that executed First FormEvent Then Istance one.

Isn't it..?
 
Alessandro could it have anything to do with the order in which the Load
event for each Subform happens? It's not a logical order if I remember
correctly.
I have only ever used WithEvents on Subforms a single level deep not the
double level you describe.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Stephen Lebans said:
Alessandro could it have anything to do with the order in which the Load
event for each Subform happens? It's not a logical order if I remember
correctly.
I have only ever used WithEvents on Subforms a single level deep not the
double level you describe.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.

Hi Stephen nice to meet you...!

Really i try to built oriented Object sistem to validate on nonlimited
level the Form's Control Value.

So i see that:

If no EVENTS are apply to the Code when i apply "[Event Procedure]"
Runtime by code on Object Class WithEvens Variable all work good.

If on SubForm i have a Code(for Ex on BeforeUpdate") my Event intercepting
procedure work only to the 2° Level, on 3° fail.

This is strage problem...!

Now i remove all Fix [Event Procedure] of any controls in each level Form
and my Classes work very fine.

I build a flexible EventSetting and multiple programmable Validate control
Events.
To return on Principal Form the Validate Action i Implements a special Class
on Principal One and on ObjectClass_Istance i Call the Istance of this
Special Class
that Callback Principal Form.

I don't know if this is clear, my bad english don't help me to make it
easy...! ;-)

This project is for a Tecnical DEMO for my Access WebSite(wich link also
your web with your
permission from 2 years) and for Italian Access WebSite more famous than
mine,
if you want see it would be a big pleasure.

Bye good week end.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top