J
Jim Shaw
Blank At "compile time" I'm getting a "Circular dependencies between
modules" error message.
What is the problem??
Is there a work-a-round?
It came up while coding my own events with the "With Events" syntax to
realize Bi-directional inter-module communicattion / synchronization via
event messaging between four forms.
Can it be that Bi-directional event messaging between sibling objects is not
allowed in VBA??!!
I got into this because of a user initiated change request that form objects
which were initially defined as independent of each other, are now
interdependent in a way that needs some type of control over the order of
event processing if I'm to save tons of existing code. Being unable to do
that directly (aparently VBA makes up its own mind on the processing order
of user raised events), I'm trying to get the form objects to explicitly
talk to each other and stay sync'd up that way.
Hopefully this background info will help...
CONTEXT: Access/2002, MS/Windows 2000 Server
The four forms are loaded in the following order
"frmEmpMaint" This is the "Main" form
"subEmpCompDataHist" A sub form on the Main form
"frmAddNewEmp" Optionally loaded by Main form logic
"frmEmp850Criteria" Optionally loaded by Main form logic
The last two forms are not normally open at the same time and there is no
attempt to communicate between them. I'm trying to keep frmEmp850Criteria
synchronized with the first two forms. Either of these three can initiate a
a need for the other two to react. I don't think "frmAddNewEmp" is part of
the problem because I had that code working.
These Events are used to synchronize (i.e.; move to related records in their
underlying table) forms:
AddedEmp(EmpID as String) signals that a new employee has been added
NewEmp(EmpID as String, Name as String) signals that a form has moved
to a new employee in its underlying file
NewEmp(RecComp as form) signals that a form has moved to a new employee
in its underlying file
CurrentRec(RecComp as form) signals that a subform has moved to a new
history record in its underlying file
SyncTo(SyncDate as date) signals a request to move to a record having
an EffectiveDate of SyncDate.
SyncOK(SyncDate as date) signals a successful move to the requested
record
SyncFailed(SyncDate as date) signals that no record exists having an
EffectiveDate of SyncDate.
RecComp is a form object which raised the event thus providing
addressability to its underlying record.
The forms have the following specifications and code snipits that I feel are
relevant to the problem:
----------------------------------------------------------------------
"frmEmpMaint"
-------------
Underlying table: tblEmployee (PK: EmpID)
Events Raised:
NewEmp(EmpID as String, Name as String)
Form850Loaded()
Events Sunk:
frmAddEmp_AddedEmp(EmpID)
Private Sub CmdNew_Click()
DoCmd.OpenForm 'frmAdNewEmp",,,....
Set frmAddEmp = Forms!frmAddNewEmp
End Sub
"frmAddNewEmp"
--------------
Underlying table: tblEmployee (PK: EmpID)
Events Raised:
AddedEmp(EmpID)
Events Sunk:
None
"subEmpCompDataHist"
--------------------
Underlying table: tblEmpCompDataHist (PK: EmpID & EffectiveDate)
Events Raised:
NewEmp(RecComp as form)
CurrentRec(RecComp as form)
SyncFailed(SyncDate as date)
SyncOK(SyncDate as date)
Events Sunk:
frmEmp_NewEmp(EmpID as String, Name as String)
frm850_SyncTo(SyncDate as date)
frmEmp_Form850Loaded()
Private Sub Form_Load()
Set frmEmp = Forms!frmEmpMaint
End Sub
Private Sub FrmEmp_Form850Loaded()
Set frm850 = Forms!frmEmp850Criteria
End Sub
"frmEmp850Criteria"
-------------------
Underlying table: Unbound form. Uses qryDefs to access needed tables &
data
Events Raised:
SyncTo(SyncDate as date)
Events Sunk:
frmComp_NewEmp(RecComp as form)
frmEmp_NewEmp(EmpID as String, Name as String)
frmComp_SyncFailed(SyncDate as date)
frmComp_SyncOK(SyncDate as date)
frmComp_CurrentRec(RecComp as form)
Private Sub Form_Load()
Set frmEmp = Forms!frmEmpMaint
Set frmComp = Forms!subEmpCompDataHist
End Sub
----------------------------------------------------------------
Believe it or not, this all makes sense to me.
Thanks
Jim
modules" error message.
What is the problem??
Is there a work-a-round?
It came up while coding my own events with the "With Events" syntax to
realize Bi-directional inter-module communicattion / synchronization via
event messaging between four forms.
Can it be that Bi-directional event messaging between sibling objects is not
allowed in VBA??!!
I got into this because of a user initiated change request that form objects
which were initially defined as independent of each other, are now
interdependent in a way that needs some type of control over the order of
event processing if I'm to save tons of existing code. Being unable to do
that directly (aparently VBA makes up its own mind on the processing order
of user raised events), I'm trying to get the form objects to explicitly
talk to each other and stay sync'd up that way.
Hopefully this background info will help...
CONTEXT: Access/2002, MS/Windows 2000 Server
The four forms are loaded in the following order
"frmEmpMaint" This is the "Main" form
"subEmpCompDataHist" A sub form on the Main form
"frmAddNewEmp" Optionally loaded by Main form logic
"frmEmp850Criteria" Optionally loaded by Main form logic
The last two forms are not normally open at the same time and there is no
attempt to communicate between them. I'm trying to keep frmEmp850Criteria
synchronized with the first two forms. Either of these three can initiate a
a need for the other two to react. I don't think "frmAddNewEmp" is part of
the problem because I had that code working.
These Events are used to synchronize (i.e.; move to related records in their
underlying table) forms:
AddedEmp(EmpID as String) signals that a new employee has been added
NewEmp(EmpID as String, Name as String) signals that a form has moved
to a new employee in its underlying file
NewEmp(RecComp as form) signals that a form has moved to a new employee
in its underlying file
CurrentRec(RecComp as form) signals that a subform has moved to a new
history record in its underlying file
SyncTo(SyncDate as date) signals a request to move to a record having
an EffectiveDate of SyncDate.
SyncOK(SyncDate as date) signals a successful move to the requested
record
SyncFailed(SyncDate as date) signals that no record exists having an
EffectiveDate of SyncDate.
RecComp is a form object which raised the event thus providing
addressability to its underlying record.
The forms have the following specifications and code snipits that I feel are
relevant to the problem:
----------------------------------------------------------------------
"frmEmpMaint"
-------------
Underlying table: tblEmployee (PK: EmpID)
Events Raised:
NewEmp(EmpID as String, Name as String)
Form850Loaded()
Events Sunk:
frmAddEmp_AddedEmp(EmpID)
Private Sub CmdNew_Click()
DoCmd.OpenForm 'frmAdNewEmp",,,....
Set frmAddEmp = Forms!frmAddNewEmp
End Sub
"frmAddNewEmp"
--------------
Underlying table: tblEmployee (PK: EmpID)
Events Raised:
AddedEmp(EmpID)
Events Sunk:
None
"subEmpCompDataHist"
--------------------
Underlying table: tblEmpCompDataHist (PK: EmpID & EffectiveDate)
Events Raised:
NewEmp(RecComp as form)
CurrentRec(RecComp as form)
SyncFailed(SyncDate as date)
SyncOK(SyncDate as date)
Events Sunk:
frmEmp_NewEmp(EmpID as String, Name as String)
frm850_SyncTo(SyncDate as date)
frmEmp_Form850Loaded()
Private Sub Form_Load()
Set frmEmp = Forms!frmEmpMaint
End Sub
Private Sub FrmEmp_Form850Loaded()
Set frm850 = Forms!frmEmp850Criteria
End Sub
"frmEmp850Criteria"
-------------------
Underlying table: Unbound form. Uses qryDefs to access needed tables &
data
Events Raised:
SyncTo(SyncDate as date)
Events Sunk:
frmComp_NewEmp(RecComp as form)
frmEmp_NewEmp(EmpID as String, Name as String)
frmComp_SyncFailed(SyncDate as date)
frmComp_SyncOK(SyncDate as date)
frmComp_CurrentRec(RecComp as form)
Private Sub Form_Load()
Set frmEmp = Forms!frmEmpMaint
Set frmComp = Forms!subEmpCompDataHist
End Sub
----------------------------------------------------------------
Believe it or not, this all makes sense to me.
Thanks
Jim