Nesting methods in Access VBA

J

JGPatrick

I would appreciate it if someone would clear up a confusion I have about VBA.
When is it OK and when is it not OK to nest methods?

For instance, the following code works fine:

Sub Prac1()

Debug.Print DBEngine.CreateWorkspace("WS1", "Admin", "", dbUseJet).Name

End Sub

But when I try to nest the CreateWorkspace method in the Workspaces.Append
method, the debug.print line generates an error message:

Sub Prac2()

Workspaces.Append DBEngine.CreateWorkspace("WS1", "Admin", "", dbUseJet)

debug.Print Workspaces(1).Name

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top