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  

CreateEventProc error



 
 
Thread Tools Display Modes
  #1  
Old February 21st, 2006, 06:45 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default CreateEventProc error

I have an app in which a controls are added to a form dynamically. After
creating the controls I want to code the KeyDown event. Here is what I have
tried;

Private Sub CreateKeyDownEvent(frmCurrent As Form, strCtlName As String)
On Error GoTo error_CreateKeyDownEvent
Dim lngReturn As Long
Dim mdl As Module
Dim strLine As String
strLine = "Call NudgeCurControl(KeyCode)" & vbCrLf & "KeyCode = 0"
Set mdl = frmCurrent.Module
lngReturn = mdl.CreateEventProc("KeyDown", strCtlName)
mdl.InsertLines lngReturn + 1, strLine
exit_CreateKeyDownEvent:
Exit Sub
error_CreateKeyDownEvent:
MsgBox Err & " :" & Err.Description
Resume exit_CreateKeyDownEvent
End Sub

When the code runs, an error is generated on the line
"lngReturn = mdl.CreateEventProc("KeyDown", strCtlName)"
The error code is 57017, Event Handler is Invalid.

I've searched high and low, but haven't had any success in determining why
the error is happening and how to avoid it.

Can anyone point me in the right direction?

thanks
--
dchman
  #2  
Old February 21st, 2006, 07:16 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default CreateEventProc error

What type of control have you added? Not all controls have a KeyDown event.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"dchman" wrote in message
...
I have an app in which a controls are added to a form dynamically. After
creating the controls I want to code the KeyDown event. Here is what I

have
tried;

Private Sub CreateKeyDownEvent(frmCurrent As Form, strCtlName As String)
On Error GoTo error_CreateKeyDownEvent
Dim lngReturn As Long
Dim mdl As Module
Dim strLine As String
strLine = "Call NudgeCurControl(KeyCode)" & vbCrLf & "KeyCode = 0"
Set mdl = frmCurrent.Module
lngReturn = mdl.CreateEventProc("KeyDown", strCtlName)
mdl.InsertLines lngReturn + 1, strLine
exit_CreateKeyDownEvent:
Exit Sub
error_CreateKeyDownEvent:
MsgBox Err & " :" & Err.Description
Resume exit_CreateKeyDownEvent
End Sub

When the code runs, an error is generated on the line
"lngReturn = mdl.CreateEventProc("KeyDown", strCtlName)"
The error code is 57017, Event Handler is Invalid.

I've searched high and low, but haven't had any success in determining why
the error is happening and how to avoid it.

Can anyone point me in the right direction?

thanks
--
dchman



  #3  
Old February 21st, 2006, 07:36 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default CreateEventProc error

textbox and combobox
--
dchman


"Douglas J Steele" wrote:

What type of control have you added? Not all controls have a KeyDown event.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"dchman" wrote in message
...
I have an app in which a controls are added to a form dynamically. After
creating the controls I want to code the KeyDown event. Here is what I

have
tried;

Private Sub CreateKeyDownEvent(frmCurrent As Form, strCtlName As String)
On Error GoTo error_CreateKeyDownEvent
Dim lngReturn As Long
Dim mdl As Module
Dim strLine As String
strLine = "Call NudgeCurControl(KeyCode)" & vbCrLf & "KeyCode = 0"
Set mdl = frmCurrent.Module
lngReturn = mdl.CreateEventProc("KeyDown", strCtlName)
mdl.InsertLines lngReturn + 1, strLine
exit_CreateKeyDownEvent:
Exit Sub
error_CreateKeyDownEvent:
MsgBox Err & " :" & Err.Description
Resume exit_CreateKeyDownEvent
End Sub

When the code runs, an error is generated on the line
"lngReturn = mdl.CreateEventProc("KeyDown", strCtlName)"
The error code is 57017, Event Handler is Invalid.

I've searched high and low, but haven't had any success in determining why
the error is happening and how to avoid it.

Can anyone point me in the right direction?

thanks
--
dchman




  #4  
Old February 21st, 2006, 08:28 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default CreateEventProc error

"dchman" wrote in message

I have an app in which a controls are added to a form dynamically.
After creating the controls I want to code the KeyDown event. Here
is what I have tried;

Private Sub CreateKeyDownEvent(frmCurrent As Form, strCtlName As
String)
On Error GoTo error_CreateKeyDownEvent
Dim lngReturn As Long
Dim mdl As Module
Dim strLine As String
strLine = "Call NudgeCurControl(KeyCode)" & vbCrLf & "KeyCode = 0"
Set mdl = frmCurrent.Module
lngReturn = mdl.CreateEventProc("KeyDown", strCtlName)
mdl.InsertLines lngReturn + 1, strLine
exit_CreateKeyDownEvent:
Exit Sub
error_CreateKeyDownEvent:
MsgBox Err & " :" & Err.Description
Resume exit_CreateKeyDownEvent
End Sub

When the code runs, an error is generated on the line
"lngReturn = mdl.CreateEventProc("KeyDown", strCtlName)"
The error code is 57017, Event Handler is Invalid.

I've searched high and low, but haven't had any success in
determining why the error is happening and how to avoid it.

Can anyone point me in the right direction?


What's the value of strCtlName within the procedure? I get that error
if I pass a zero-length string for the strCtlName argument. If I pass a
valid control name, it works for me.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


  #5  
Old February 21st, 2006, 09:18 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default CreateEventProc error

Your code worked for me with a textbox.

As Dirk suggested, are you sure you're passing the correct value for
strCtlName?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"dchman" wrote in message
...
textbox and combobox
--
dchman


"Douglas J Steele" wrote:

What type of control have you added? Not all controls have a KeyDown

event.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"dchman" wrote in message
...
I have an app in which a controls are added to a form dynamically.

After
creating the controls I want to code the KeyDown event. Here is what

I
have
tried;

Private Sub CreateKeyDownEvent(frmCurrent As Form, strCtlName As

String)
On Error GoTo error_CreateKeyDownEvent
Dim lngReturn As Long
Dim mdl As Module
Dim strLine As String
strLine = "Call NudgeCurControl(KeyCode)" & vbCrLf & "KeyCode = 0"
Set mdl = frmCurrent.Module
lngReturn = mdl.CreateEventProc("KeyDown", strCtlName)
mdl.InsertLines lngReturn + 1, strLine
exit_CreateKeyDownEvent:
Exit Sub
error_CreateKeyDownEvent:
MsgBox Err & " :" & Err.Description
Resume exit_CreateKeyDownEvent
End Sub

When the code runs, an error is generated on the line
"lngReturn = mdl.CreateEventProc("KeyDown", strCtlName)"
The error code is 57017, Event Handler is Invalid.

I've searched high and low, but haven't had any success in determining

why
the error is happening and how to avoid it.

Can anyone point me in the right direction?

thanks
--
dchman






  #6  
Old February 21st, 2006, 10:50 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default CreateEventProc error

thanks for taking a look at this. I checked the value for strCtlName and it
is a valid control on the form, so i'm not sure what is going on. I'm doing
this on an existing form, which I've opened with the acDesign option, so that
I can create controls, and have tried adding the event procedure both before
and after saving the form to no avail. The examples I've seen are always for
new forms. Do think that matters?
--
dchman


"Dirk Goldgar" wrote:

"dchman" wrote in message

I have an app in which a controls are added to a form dynamically.
After creating the controls I want to code the KeyDown event. Here
is what I have tried;

Private Sub CreateKeyDownEvent(frmCurrent As Form, strCtlName As
String)
On Error GoTo error_CreateKeyDownEvent
Dim lngReturn As Long
Dim mdl As Module
Dim strLine As String
strLine = "Call NudgeCurControl(KeyCode)" & vbCrLf & "KeyCode = 0"
Set mdl = frmCurrent.Module
lngReturn = mdl.CreateEventProc("KeyDown", strCtlName)
mdl.InsertLines lngReturn + 1, strLine
exit_CreateKeyDownEvent:
Exit Sub
error_CreateKeyDownEvent:
MsgBox Err & " :" & Err.Description
Resume exit_CreateKeyDownEvent
End Sub

When the code runs, an error is generated on the line
"lngReturn = mdl.CreateEventProc("KeyDown", strCtlName)"
The error code is 57017, Event Handler is Invalid.

I've searched high and low, but haven't had any success in
determining why the error is happening and how to avoid it.

Can anyone point me in the right direction?


What's the value of strCtlName within the procedure? I get that error
if I pass a zero-length string for the strCtlName argument. If I pass a
valid control name, it works for me.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)



  #7  
Old February 21st, 2006, 11:03 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default CreateEventProc error

I used an existing form when I tested it.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"dchman" wrote in message
...
thanks for taking a look at this. I checked the value for strCtlName and
it
is a valid control on the form, so i'm not sure what is going on. I'm
doing
this on an existing form, which I've opened with the acDesign option, so
that
I can create controls, and have tried adding the event procedure both
before
and after saving the form to no avail. The examples I've seen are always
for
new forms. Do think that matters?
--
dchman


"Dirk Goldgar" wrote:

"dchman" wrote in message

I have an app in which a controls are added to a form dynamically.
After creating the controls I want to code the KeyDown event. Here
is what I have tried;

Private Sub CreateKeyDownEvent(frmCurrent As Form, strCtlName As
String)
On Error GoTo error_CreateKeyDownEvent
Dim lngReturn As Long
Dim mdl As Module
Dim strLine As String
strLine = "Call NudgeCurControl(KeyCode)" & vbCrLf & "KeyCode = 0"
Set mdl = frmCurrent.Module
lngReturn = mdl.CreateEventProc("KeyDown", strCtlName)
mdl.InsertLines lngReturn + 1, strLine
exit_CreateKeyDownEvent:
Exit Sub
error_CreateKeyDownEvent:
MsgBox Err & " :" & Err.Description
Resume exit_CreateKeyDownEvent
End Sub

When the code runs, an error is generated on the line
"lngReturn = mdl.CreateEventProc("KeyDown", strCtlName)"
The error code is 57017, Event Handler is Invalid.

I've searched high and low, but haven't had any success in
determining why the error is happening and how to avoid it.

Can anyone point me in the right direction?


What's the value of strCtlName within the procedure? I get that error
if I pass a zero-length string for the strCtlName argument. If I pass a
valid control name, it works for me.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)





  #8  
Old February 22nd, 2006, 03:16 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default CreateEventProc error

"Douglas J. Steele" wrote in
message
I used an existing form when I tested it.


Same here. The code works for me. Is it possible the form already has
an event procedure for that control and event? I didn't test that
circumstance.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


  #9  
Old February 22nd, 2006, 06:15 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default CreateEventProc error

Since you'all could do it, i decided to try it in a new database outside of
my application, and I was also successful. After much consternation, I
noticed that the controls in my application had names which contain the pipe
character |, while my test case didn't. I changed how the controls were
named and presto, success, with one quirk.

At the end of the sub in which I add the controls and event procedures, I
close the form on which the controls exist (it is not the active form) with

DoCmd.Close acForm, frm.Name, acSaveYes

I thought is would save the form without a prompt, but when this line runs,
I am still prompted to save. Any ideas?

Thanks for assistance.
--
dchman


"Dirk Goldgar" wrote:

"Douglas J. Steele" wrote in
message
I used an existing form when I tested it.


Same here. The code works for me. Is it possible the form already has
an event procedure for that control and event? I didn't test that
circumstance.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)



  #10  
Old February 22nd, 2006, 06:59 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default CreateEventProc error

"dchman" wrote in message

Since you'all could do it, i decided to try it in a new database
outside of my application, and I was also successful. After much
consternation, I noticed that the controls in my application had
names which contain the pipe character |, while my test case didn't.
I changed how the controls were named and presto, success, with one
quirk.


There may be a way to work around that, but the pipe characters were
definitely not a good idea.

At the end of the sub in which I add the controls and event
procedures, I close the form on which the controls exist (it is not
the active form) with

DoCmd.Close acForm, frm.Name, acSaveYes

I thought is would save the form without a prompt, but when this line
runs, I am still prompted to save. Any ideas?


I tried this, and found that I was not prompted to save, *provided* that
this form was the only object that needed saving.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reserved Error - 1104 - Works in 97 not in XP? beveritt General Discussion 0 August 25th, 2005 05:07 PM
Error message different in MDB and MDE david epsom dot com dot au General Discussion 1 September 21st, 2004 12:47 AM
Continual Error 1321 Trying to Install Office 2003 Chad Harris General Discussions 9 June 11th, 2004 08:19 AM
Product Key for Office XP P.G.Indiana Setup, Installing & Configuration 1 June 7th, 2004 03:22 AM
Error #1321 MOS 2003 Setup Chad Harris Setup, Installing & Configuration 1 June 7th, 2004 12:22 AM


All times are GMT +1. The time now is 07:17 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.