Module to open ADO connection at apps start (1 Viewer)

freuzo

Member
Local time
Today, 18:49
Joined
Apr 14, 2020
Messages
98
Hi everyone, I hope y'all doing great.
I'm starting a ms access apps with MySql as BE. It will be over the internet.
Now I don't have problems with open an ADO Connection or a Recordset.
What I need to do is to create a module to establish the connection at the start, so I'll not have to repeat those lines in every bunch of code.
I read that is the best way but I good enough to create that module by myself yet, so I need you guys.

Thanks.
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 03:49
Joined
Jan 20, 2009
Messages
12,851
Basically create a user defined function in a Standard Module and return the Connection Object.

I've done it using a class with a Private Collection (or Dictionary) of connections presented as members of the class. (I used to have two servers at the time before I linked them and ultimately consolidated them into one.)

The calling sub asks for a connection by name and the class transparently checks to see if it is already in the Collection and creates it if necessary or simply returns the existing one. (That is where the Dictionary is superior because you can enquire against a Dictionary by name.

The code to close them when you finish can be in the class to so it is very tidy.
 

freuzo

Member
Local time
Today, 18:49
Joined
Apr 14, 2020
Messages
98
Thanks for the reply.
My skills are not up to those kind of things yet. Could you provide me some example ?
 

Users who are viewing this thread

Top Bottom