Connecting Tech Pros Worldwide Help | Site Map

Generating event-code in MS-access

  #1  
Old November 12th, 2005, 09:26 PM
Tom Seichter
Guest
 
Posts: n/a
Hi there,

I want to generate reports with a fixed behavior for the Close event.
Therefor I'm programming a function like

Function CreateEvent() ...
Dim rpt as Report, mdl as Module, lngReturn as Long
Set rpt = CreateReport
rpt.HasModule = True
Set mdl = rpt.Module
lngReturn = mdl.CreateEventProc("OnClose", rpt.Name)
....

My problem is an error-message: '57017, Event-Routine not valid' I
always get when I'm executing the CreateEventProc() function. I
changed the first argument to 'Close', 'Close()', 'OnClose()'... but
the error-message is the same.
Does someone can help me, what is the correct value of this argument,
or give me a hint what error I'm doing.

Thanks Tom
  #2  
Old November 12th, 2005, 09:26 PM
Larry Linson
Guest
 
Posts: n/a

re: Generating event-code in MS-access


Is there some compelling reason why you'd want to create the Report and the
code via code, rather than doing it in design view? You can create both that
you modify with code at runtime if necessary, but the kind of thing you
illustrate is normally only used in Wizards and such to run at design time.

Larry Linson
Microsoft Access MVP

"Tom Seichter" <tomancer@netscape.net> wrote in message
news:13742567.0403071344.614cc13b@posting.google.c om...[color=blue]
> Hi there,
>
> I want to generate reports with a fixed behavior for the Close event.
> Therefor I'm programming a function like
>
> Function CreateEvent() ...
> Dim rpt as Report, mdl as Module, lngReturn as Long
> Set rpt = CreateReport
> rpt.HasModule = True
> Set mdl = rpt.Module
> lngReturn = mdl.CreateEventProc("OnClose", rpt.Name)
> ...
>
> My problem is an error-message: '57017, Event-Routine not valid' I
> always get when I'm executing the CreateEventProc() function. I
> changed the first argument to 'Close', 'Close()', 'OnClose()'... but
> the error-message is the same.
> Does someone can help me, what is the correct value of this argument,
> or give me a hint what error I'm doing.
>
> Thanks Tom[/color]


  #3  
Old February 24th, 2006, 02:12 PM
Newbie
 
Join Date: Feb 2006
Posts: 4

re: Generating event-code in MS-access


I don't think that the answer of Larry was very helpfull.
Hopefully mine is better... :rolleyes:

Dim frm As Form, mdl As Module
Dim strName As String

Set frm = CreateForm
strName = frm.Name

Return reference to form module.
Set mdl = frm.Module

' Add event procedure for the Form Close Event
mdl.InsertLines mdl.CountOfLines + 1, "Private Sub Form_Close()"
mdl.InsertLines mdl.CountOfLines + 1, vbTab & "'Here your code"
mdl.InsertLines mdl.CountOfLines + 1, "end sub"
frm.OnClose = "[Event Procedure]"

DoCmd.Save acForm, frm.Name
DoCmd.Close acForm, frm.Name
DoCmd.Rename "MyFormName", acForm, strName



Quote:
Originally Posted by Larry Linson
Is there some compelling reason why you'd want to create the Report and the
code via code, rather than doing it in design view? You can create both that
you modify with code at runtime if necessary, but the kind of thing you
illustrate is normally only used in Wizards and such to run at design time.

Larry Linson
Microsoft Access MVP

"Tom Seichter" <tomancer@netscape.net> wrote in message
news:13742567.0403071344.614cc13b@posting.google.c om...[color=blue]
> Hi there,
>
> I want to generate reports with a fixed behavior for the Close event.
> Therefor I'm programming a function like
>
> Function CreateEvent() ...
> Dim rpt as Report, mdl as Module, lngReturn as Long
> Set rpt = CreateReport
> rpt.HasModule = True
> Set mdl = rpt.Module
> lngReturn = mdl.CreateEventProc("OnClose", rpt.Name)
> ...
>
> My problem is an error-message: '57017, Event-Routine not valid' I
> always get when I'm executing the CreateEventProc() function. I
> changed the first argument to 'Close', 'Close()', 'OnClose()'... but
> the error-message is the same.
> Does someone can help me, what is the correct value of this argument,
> or give me a hint what error I'm doing.
>
> Thanks Tom[/color]
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
mouse click generation drfabius2000@hotmail.com answers 2 January 25th, 2006 02:15 PM
"Add Reference" hosed--doesn't display the dialog in VS.NET Samuel R. Neff answers 3 November 21st, 2005 03:23 PM
Problem in ASP.Net File Upload Application Pitcairnia answers 3 November 19th, 2005 11:06 AM
how to force Thread.Abort() to Abort ? Andy Fish answers 13 November 16th, 2005 07:03 PM
DBCC and Failed Assertion Errors - HELP! Morgan Leppink answers 4 July 20th, 2005 05:00 AM