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/