Setting ODBC in VBA Code

Kingz

Member
Local time
Today, 20:14
Joined
Mar 19, 2024
Messages
56
Hi,

I have a few Passthrough queries, which function via an odbc connection. With VBA, I have a form where I can update the queries using query Defs.
What I've noticed, is that when I start the program fresh, it will give me an ODBC error, however, if I go to my queries and execute one by clicking on it, then the connection is created successfully and my application works without any odbc error. So by manually coughing a pass through query, the connection is created. How can I do that in VBA, since the error is a little tedious.
I presume I'll have to somehow initiate the odbc connection somehow
 
Look at the code which runs on startup. Perhaps in an AutoExec macro. Perhaps in a startup form. Something in that code is not doing what it should be doing.

Showing us the actual Error Message might also help someone recognize the actual problem, too...
 
I'm assuming you have re-link code in your startup code, which would set the (possibly new) connection string of all linked tables.
It needs to do that for PT queries as well. They also have a Connect property.
 
I'm assuming you have re-link code in your startup code, which would set the (possibly new) connection string of all linked tables.
It needs to do that for PT queries as well. They also have a Connect property.
Oh I see .I don't have that.. What does that look like? All I do in my code is set some variables in my query which I set as querydef.. My code assumes the user has an ODBC connection to the database for the pass through queries to work. In fact, I personally don't get the odbc error message, which is why I haven't published it here, but I can see that needs to be aligned somehow. It would be great to see code for that. Thanks in advance.
 

Users who are viewing this thread

Back
Top Bottom