RaiseEvent isn't raising

C

CDM

I'm trying to synchronize two forms using withevents, but nothing happens
with the command line 'raiseevent'. Here is my code:
MainForm
Public Event NewCustomer(strCustomer_Id as string)

Private sub txtCustomer_Id_afterupdate
RaiseEvent NewCustomer(me!txtCustomer_Id)

2ndForm
Dim WithEvents frm as Form_MainForm

Private Sub Form_Load
Set frm = Form_MainForm

Private sub frm_NewCustomer(mCustomer_Id as String)
'Update 2ndForm

My problem is that nothing happens with RaiseEvent in the MainForm.
Execution goes on as if this line was just a comment. Any ideas?
 
R

Rob Cooper [MSFT]

The issue is in the Load event of the 2nd form. Form_MainForm is the class
representing the form, but not an instance of the class so no events are
fired. To receive events for a given instance of the form, try:

Set frm = Forms("MainForm")

Hope this helps,

--
Rob Cooper
Lead Software Design Engineer in Test
Microsoft Access Team

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
microsoft.com/info/cpyright.htm.
 
C

CDM

Many thanks.

Rob Cooper said:
The issue is in the Load event of the 2nd form. Form_MainForm is the class
representing the form, but not an instance of the class so no events are
fired. To receive events for a given instance of the form, try:

Set frm = Forms("MainForm")

Hope this helps,

--
Rob Cooper
Lead Software Design Engineer in Test
Microsoft Access Team

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
microsoft.com/info/cpyright.htm.
 

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

Top