473,395 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

create an sql connection and use it from different subs and modules

24
Hello,
can somebody please help me with the following,
i want to create an sql connection and use it from different subs and modules.
for example:
constr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
FRM_BALCANOR.TextBoxDB.Text & "BOGGERDB.mdb" & ";"

Dim con As ADODB.Connection
Set con = New ADODB.Connection
con.ConnectionString = constr
Dim recset As ADODB.Recordset
Dim cn As ADODB.Connection

and use the same connection which is opened to be used from another vba module and sub.

Thanks a lot
Sep 24 '07 #1
3 1681
cyberdwarf
218 Expert 100+
You could use a global variable to hold your connection string, but I have a question...

Why can't you use CurrentProject.Connection property, as this is valid for all forms/reports/modules in the project? Or are you saying that a connection (different to the CurrentProject.Connection) used with a particular form/recordset will be used elsewhere?

Sorry if I sound a bit confused....

Steve
Sep 24 '07 #2
TSIGOS1
24
Yes ok,
I am trying to open a odbc con from Excel and use it for 2 specific subs.How do I make it global?
Sep 24 '07 #3
cyberdwarf
218 Expert 100+
Why are you using ODBC, not ADO?
Sep 24 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: dw | last post by:
Which is the most efficient way to hit the database: 1) to open/close the connection for each call to the database on a page (we have Subs that do this); 2) or use the same connection and close it...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
1
by: Pete Straman Straman via AccessMonster.com | last post by:
Hey: I have created a module that runs fine. I am trying to put all my modules on a form. I cannot get the modules to run from the command buttons. The error I get is Compiler error: ...
4
by: MLH | last post by:
If I test the integrity of my code, opening a module, clicking Debug, Compile All Modules, the process stops at the first occurrence of a coding error. Can I skip that and go on somehow (you know,...
3
by: Jul | last post by:
Hi, I need to create copy (clone) the OracleConnection object. The OracleConnection class does not contain "Clone" method for creating copy. It contains Protected MemberwiseClone but if use...
1
by: pob | last post by:
>From a form I have some code that calls 4 modules frmMain 1 mod 2 mod 3 mod 4 mod If mod 1 experiences an error the error handling works fine within mod 1 and writes out the error to a...
4
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the...
3
by: 100grand | last post by:
Modify the Inventory Program to use a GUI. The GUI should display the information one product at a time, including the item number, the name of the product, the number of units in stock, the price...
167
by: darren | last post by:
Hi I have to write a multi-threaded program. I decided to take an OO approach to it. I had the idea to wrap up all of the thread functions in a mix-in class called Threadable. Then when an...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.