473,320 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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
Nov 12 '05 #1
2 4251
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" <to******@netscape.net> wrote in message
news:13**************************@posting.google.c om...
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

Nov 12 '05 #2
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



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]
Feb 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ganesh | last post by:
hi pals, I like to know ,how to generate a mouse event through the java program .. the user should not need to trigger the mouse event.the program should control the mouse to generate a mouse...
2
by: Liz - Newbie | last post by:
I need to generate an event in a user defined control when I have changed a variable, so that I can pick it up in my main form and take it from there. Can someone explain the SIMPLEST way of...
4
by: Lee Chapman | last post by:
Hi, I am having difficulty getting the ASP.NET framework to generate valid XHTML. My immediate problem surrounds user input in, for example, textbox controls. I consider characters such as...
4
by: Bill J | last post by:
Hi Everyone, Is there a way of generating a keyboard character event and sending it to a control on a form? For example, if I have a menu item called "Delete", I would like to send a DEL...
0
by: krish | last post by:
hi, I am dynamically generating Imagebutton (say 5 imagebutton, in loop) . for each imagebutton url , i am dynamically generating image and assigining to it. every thing is ok upto this...
3
by: deciacco | last post by:
I'm trying to write a label printing SDI app with a small preview on the main form itself. Every time I run the InvalidatePreview event on the preview control to redraw the preview I get the...
1
by: NayJo | last post by:
I am writing a .NET 2.0 Windows Form app that accepts either keyed or scanned data via a barcode scanner via SerialPort into one column of a DataGridView control. The program handles scanned...
0
by: Aswanth | last post by:
I'm Generating Reports in SSRS-2005.. Previously I got the Data from One Database & Generated Reports.. Now I used to get the Data from Two Different Databases(ie Database-1 & Database-2) & to...
6
by: Gandalf | last post by:
I have script which being triggered by pressing CTRL+Right mouse click from any place in my O.P , Now I need to generate automatically event like copy my selected item or double clicking the right...
3
by: Hamayun Khan | last post by:
Hi I want to trigger an event after every 20 minutes. Is it Possible. Thanks
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.