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 / General 1 / July 2006

Tip: Looking for answers? Try searching our database.

VBA Access - Moving parts of a program to DLLs? Error 91.. "Object variable or With block variable not set"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
axs221 - 21 Jul 2006 22:15 GMT
I am trying to move some of our large VBA Access front-end file into
ActiveX DLL files. I created two DLL files so far, one was a module
that contains code to integrate into the QuickBooks accounting
software. Another has general utilities.

I tried referencing the utilities dll, and it shows up in the object
explorer. I instantiated an instance of the class and now it shows up
all okay in the Intellisense. Whenever I try to run a simple function,
though, even a subroutine that just does:

MsgBox "Test"

It gives me the error 91: Object variable or With block variable not
set

Am I missing a step here? We really need these DLLs, or some
alternative, so that we can better use Subversion for our main project.
David W. Fenton - 21 Jul 2006 23:16 GMT
> I am trying to move some of our large VBA Access front-end file
> into ActiveX DLL files.

Why in the *world* would you do such a thing?

Signature

David W. Fenton                  http://www.dfenton.com/
usenet at dfenton dot com    http://www.dfenton.com/DFA/

axs221 - 22 Jul 2006 00:41 GMT
Do you have a better idea? We need to split apart our main program,
which is ALL in one database file. It defeats part of the purpose of
using Subversion to have only one file. It takes too long to
synchronize and doesn't allow more than one person to work on the file
without having to later merge bits and pieces together. A separate file
like a DLL library would allow me to work on my Quickbooks integration
portion of the code while the other programmer could work on whatever
he's working on. If there's a better way to do it in VBA then feel free
to enlighten me.

> > I am trying to move some of our large VBA Access front-end file
> > into ActiveX DLL files.
[quoted text clipped - 4 lines]
> David W. Fenton                  http://www.dfenton.com/
> usenet at dfenton dot com    http://www.dfenton.com/DFA/
David W. Fenton - 22 Jul 2006 17:23 GMT
>> > I am trying to move some of our large VBA Access front-end file
>> > into ActiveX DLL files.
[quoted text clipped - 11 lines]
> there's a better way to do it in VBA then feel free to enlighten
> me.

I know of Access projects using SourceSafe and such products for
this.

I don't see the issue. Don't those products work for you?

Signature

David W. Fenton                  http://www.dfenton.com/
usenet at dfenton dot com    http://www.dfenton.com/DFA/

Bri - 25 Jul 2006 00:46 GMT
> Do you have a better idea? We need to split apart our main program,
> which is ALL in one database file. It defeats part of the purpose of
[quoted text clipped - 5 lines]
> he's working on. If there's a better way to do it in VBA then feel free
> to enlighten me.

From this response I get the idea that you are using Replication with
this app? And that the UI and data are in the same MDB? If these
assumptions are so, then you should look at splitting the database and
only replicating the data. Replication of the application objects is
very prone to problems. If these assumptions are not so, then we will
move on to Libraries.

You can set up a MDB file with all the code you want to separate from
the  main app. Then you can create an MDE from the MDB that you can then
reference in the main app. This would keep all the coding in the same
environment.

--
Bri
axs221 - 25 Jul 2006 16:05 GMT
We use replication for our data, but our data is in a separate MDB
file. As for libraries, I do want to move some code into other
libraries, but with how my company has our code set up it isn't too
smooth of a transition.

I've made a separate MDB file now for one module in our program, but
now the issue is trying to handle function calls that were in other
sections of the main database of the program, along with any queries or
the few globals that we use for keeping track of certain files and
things. Since the separate MDB can't refer back to the main program, I
created a third library for the calls that both databases need, but
this is kind of a hassle and might get messy. Is there a better way of
handling that?

Shawn

> > Do you have a better idea? We need to split apart our main program,
> > which is ALL in one database file. It defeats part of the purpose of
[quoted text clipped - 20 lines]
> --
> Bri
Bri - 25 Jul 2006 17:28 GMT
> We use replication for our data, but our data is in a separate MDB
> file. As for libraries, I do want to move some code into other
> libraries, but with how my company has our code set up it isn't too
> smooth of a transition.

Good, for a while there I thought you had been using replication to
distribute code changes. That was one of the original uses of
Replication, but it was so prone to problems that anyone in the know
about Replication now strongly recommends against it.

> I've made a separate MDB file now for one module in our program, but
> now the issue is trying to handle function calls that were in other
[quoted text clipped - 4 lines]
> this is kind of a hassle and might get messy. Is there a better way of
> handling that?

I'm by no means an expert on Libraries, but I would think that if there
is something in the main program that the library function needs to know
about (variable, object, etc) that if you were to include it in the
parameters of the function call that would take care of things. This is
very similar to moving a function from a Form module, that has all sorts
of Me referrences, to a stand alone module (so it can work with more
than one form). For a simple function, I'll show what I mean with some
air code:

Code in Form:
Function ControlChanged() As Boolean
   If Me!MyText.Value<>Me!MyText.OldValue Then
      ControlChanged = True
   Else
      ControlChanged = False
   End If
End Function

Code in Module:
Function ControlChanged(frm As Form) as Boolean
   If frm!MyText.Value<>frm!MyText.OldValue Then
      ControlChanged = True
   Else
      ControlChanged = False
   End If
End Function

Or if you need to be able to refer to any control:
Function ControlChanged(ctr As Control) as Boolean
   If ctr.Value<>ctr.OldValue Then
      ControlChanged = True
   Else
      ControlChanged = False
   End If

So, if you pass the appropriate Parameters, you should be able to make
the functions in the Library able to work even though they are isolated
from the main app. You mentioned Global Variables as well. If the
function only needs to refer to a few of them you can include them in
the parameters. There are a number of ways you could pass them all at
once if you needed to have the function be able to refer to any/all of
them. You could load them into an array ( GlobalArray(varName, varValue)
) and pass the array as a parameter. You could load them into a
Collection. Or for the ultimate in flexibility (and complexity too) you
could load them into a Class.

Obviously, the code that is the best candidate for a Library is code
that can easily stand alone with the minimum of parameters, but that
doesn't mean you can't deal with anything else. There will be a limit to
what you can practically move to the Library.

Hope that helped.

--
Bri
David W. Fenton - 26 Jul 2006 00:35 GMT
> I've made a separate MDB file now for one module in our program,
> but now the issue is trying to handle function calls that were in
> other sections of the main database of the program, along with any
> queries or the few globals that we use for keeping track of
> certain files and things.

Don't use globals.

Seriously.

There are simply very few circumstances in which a global variable
is a good way to share data. A global constant is a different
animal, and perfectly OK. If you've got lots of those, you could do
what Bri suggested, pass a structure to the code in the library.

I've used libraries plenty of times and this has just never been an
issue. Any code that's in a library oughtn't be dependent on globals
of any kind, it seems to me. That's an obvious architectural
requirement, it seems to me.

Signature

David W. Fenton                  http://www.dfenton.com/
usenet at dfenton dot com    http://www.dfenton.com/DFA/

Tom van Stiphout - 22 Jul 2006 04:27 GMT
First set a reference (code window > Tools > References) to one of
your DLLs. At that point it would show in Intellisense and Object
Browser.
Then create an object, and call its methods. For the Utilities DLL,
you probably would have a global object:
(in a standard module)Global g_objUtil as Utilities.Utils
(in your startup code)Set g_objUtil = New Utilties.Utils
(in the rest of your code)Msgbox g_objUtil.DoSomething()
(in your exit code)Set g_objUtil = Nothing

Unlike David I don't think modularization in ActiveX DLLs is a bad
idea to support multiple-developer development (MDD). One thing that
might possibly prevent me from doing it is that you rely on VB6 and
ActiveX, which are aging technologies.
I would definitely not encourage MDD using SourceSafe integration.

-Tom.

>I am trying to move some of our large VBA Access front-end file into
>ActiveX DLL files. I created two DLL files so far, one was a module
[quoted text clipped - 13 lines]
>Am I missing a step here? We really need these DLLs, or some
>alternative, so that we can better use Subversion for our main project.
axs221 - 22 Jul 2006 16:09 GMT
You know, I think I actually left out the constructor call, silly me.
That message would make sense if the object wasn't instantiated... I
was just happy to see the object in the Intellisense.

Thanks, I'll have to give that a try on Monday.

> First set a reference (code window > Tools > References) to one of
> your DLLs. At that point it would show in Intellisense and Object
[quoted text clipped - 31 lines]
> >Am I missing a step here? We really need these DLLs, or some
> >alternative, so that we can better use Subversion for our main project.
 
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.