Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old November 12th, 2005, 09:26 PM
Tom Seichter
Guest
 
Posts: n/a
Default Generating event-code in MS-access

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
Default 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
Default Solution!!!

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]
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,414 network members.