Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / January 2005

Tip: Looking for answers? Try searching our database.

Nested SUBs?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dennis - 27 Jan 2005 18:59 GMT
I'm trying to convert (and recompile) a 2000 database. In the form, I have
something like:

-------------------------
Private Sub SUB1
Private Sub SUB2
...
...
...
End Sub
End Sub
-------------------------

As I'm sure you can imagine, Access is barfing on attempted compilation. WTH
is going on here? Any insight would be most appreciated.

Thanks!
Dirk Goldgar - 27 Jan 2005 19:06 GMT
> I'm trying to convert (and recompile) a 2000 database. In the form, I
> have something like:
[quoted text clipped - 14 lines]
>
> Thanks!

Code like that could never have worked, but you're only now discovering
it because the conversion involves recompiling.  You'll have to sort out
what the correct code should have been, with the two procedures not
nested, and fix it.  Or else conclude that the object containing that
code is not used, because one would expect some sort of error if you
tried to run any code in it, given that the module is uncompilable.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Albert D. Kallal - 28 Jan 2005 00:49 GMT
Well, Pascal / Delphi always did allow sub, and function nesting, and it is
wonderful feature that I miss!!

When you nest functions (in a language that lets you do this), then those
functions are LOCAL to the particular sub!

For ms-access, to group functions and subs this way, you have to put them
all in a similar module, and use public/private. With Pascal, the fact of
declaring subs/functions works exactly on a conceptual level the same way
that global/local vars work in ms-access. If you needed a function to ONLY
be fore use with the current sub, then you declare the function *inside* of
the sub..and it is instantly local!

A good many languages did support this feature...and I often miss it....

Signature

Albert D. Kallal   (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com
http://www.members.shaw.ca/AlbertKallal

Dirk Goldgar - 28 Jan 2005 01:17 GMT
> Well, Pascal / Delphi always did allow sub, and function nesting, and
> it is wonderful feature that I miss!!
[quoted text clipped - 11 lines]
> A good many languages did support this feature...and I often miss
> it....

Sure, I've programmed in many such languages.  Unfortunately for Dennis,
VBA isn't one of them. <g>

Working in Access VBA, I have occasionally ended up with nested Subs
like that, when I accidentally pasted code in the wrong place.  I think
it's more likely that a mistake of that sort happened here, rather than
it being the result of a programmer who thought he was working in a
different language.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

PC Datasheet - 27 Jan 2005 19:10 GMT
You can't nest subs this way! Do this:
Private Sub SUB1
   Call SUB2

End Sub

Public Sub Sub2

End Sub

--
                                       PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
                             resource@pcdatasheet.com
                                www.pcdatasheet.com

> I'm trying to convert (and recompile) a 2000 database. In the form, I have
> something like:
[quoted text clipped - 13 lines]
>
> Thanks!
Dennis - 27 Jan 2005 21:31 GMT
Yeah, I know that. But that's the way it's currently coded. Needless to say,
it doesn't compile....

> You can't nest subs this way! Do this:
> Private Sub SUB1
[quoted text clipped - 30 lines]
> >
> > Thanks!
PC Datasheet - 28 Jan 2005 00:10 GMT
Did you notice I provided what the code should be????

--
                                       PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
                             resource@pcdatasheet.com
                                www.pcdatasheet.com

> Yeah, I know that. But that's the way it's currently coded. Needless to say,
> it doesn't compile....
[quoted text clipped - 33 lines]
> > >
> > > Thanks!
Dennis - 28 Jan 2005 14:25 GMT
Yes (thanks). The moment I saw that bizarre structure I knew it couldn't
work. I was just wondering if anyone else had seen a case where something
similar DID work (I would've been shocked and amazed). I just wanted to cover
all the bases.

Thanks again!

> Did you notice I provided what the code should be????
>
[quoted text clipped - 44 lines]
> > > >
> > > > Thanks!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.