A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Calling Event Procedure from a Form Variable



 
 
Thread Tools Display Modes
  #1  
Old November 14th, 2009, 09:07 PM posted to microsoft.public.access.forms
Mark A. Sam[_3_]
external usenet poster
 
Posts: 468
Default Calling Event Procedure from a Form Variable

Hello,

I would like to call an event procedure from a form variable. Can it be
done? I tried this, and got a message:

Runtime error '2465':
Application-Defined or Object-Defined error.


DoCmd.OpenForm "Order Entry Header Admin", , , "[OrdID] =" & [ordID]

Dim frm As Form
Set frm = Forms("Order Entry Header Admin")
Call frm.Copy_Record_Click

Set frm = Nothing

Can this be done or is my method just wrong.

Thank you for your help and God Bless,

Mark A. Sam



  #2  
Old November 14th, 2009, 11:05 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Calling Event Procedure from a Form Variable

"Mark A. Sam" wrote in message
...
Hello,

I would like to call an event procedure from a form variable. Can it be
done? I tried this, and got a message:

Runtime error '2465':
Application-Defined or Object-Defined error.


DoCmd.OpenForm "Order Entry Header Admin", , , "[OrdID] =" & [ordID]

Dim frm As Form
Set frm = Forms("Order Entry Header Admin")
Call frm.Copy_Record_Click

Set frm = Nothing

Can this be done or is my method just wrong.



You can do it, but the procedure you call must be Public, not Private.
Since event procedures are Private by default (e.g., "Private Sub
Copy_Record_Click()"), you must modify the event procedure's code to make it
Public:

Public Sub Copy_Record_Click()


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #3  
Old November 15th, 2009, 03:24 AM posted to microsoft.public.access.forms
Mark A. Sam[_3_]
external usenet poster
 
Posts: 468
Default Calling Event Procedure from a Form Variable

Thank you Dirk.


"Dirk Goldgar" wrote in message
...
"Mark A. Sam" wrote in message
...
Hello,

I would like to call an event procedure from a form variable. Can it be
done? I tried this, and got a message:

Runtime error '2465':
Application-Defined or Object-Defined error.


DoCmd.OpenForm "Order Entry Header Admin", , , "[OrdID] =" & [ordID]

Dim frm As Form
Set frm = Forms("Order Entry Header Admin")
Call frm.Copy_Record_Click

Set frm = Nothing

Can this be done or is my method just wrong.



You can do it, but the procedure you call must be Public, not Private.
Since event procedures are Private by default (e.g., "Private Sub
Copy_Record_Click()"), you must modify the event procedure's code to make
it Public:

Public Sub Copy_Record_Click()


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


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


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.