Thread: Access
View Single Post
  #5  
Old May 4th, 2010, 03:35 PM posted to microsoft.public.access.gettingstarted
bcraigmiles via AccessMonster.com
external usenet poster
 
Posts: 3
Default Access

Thanks.

KenSheridan wrote:
Where have you entered the code? The error you are getting normally means
that code has been entered in a module, be it a standard module or a form or
report's class module, outside the procedure declaration line and the End Sub
line which marks the end of the procedure. The code must be between these
lines.

The error occurs on the 'Set cmd = New ADODB.Command' line because the lines
prior to that are merely constant or variable declarations, which are
permissible outside a procedure, so this line is the first to raise an error.

If you are opening the report from a button on a form for instance, select
the button in form design view. In its properties sheet select the On Click
even property and then click the 'build' button (the one on the right with 3
dots). Select 'Code Builder' in the next dialogue and OK out of the dialogue.
The VBA window should open at the control's Click event procedure with the
first and last lines in place. Paste the code between these two lines.

Ken Sheridan
Stafford, England

I tried this and got the following error:
Compile Error: Invalid outside procedure. There is something about the

[quoted text clipped - 5 lines]
I would like to consecutively number an Access report each time it runs so
that I know how many times this report has run. Can anyone help?


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...arted/201005/1