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
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