14880 Pass-Through Query with Parameters from a Table
Sign Up |  Live StatsLive Stats    Articles 37,330| Comments 177,262| Members 19,413, Newest psgujral| Online 449
Home Contact
 (Forgotten?): 
    Sikhism
    For best SPN experience, use Firefox Internet Browser!


                                                                   Your Banner Here!    




Click Here to Register/Sign Up Daily Hukamnama Member Blogs Downloads Website Navigation Help Fonts Tags
Sikh Philosophy Network » Sikh Philosophy Network » Current News » Information Technology » Pass-Through Query with Parameters from a Table

Pass-Through Query with Parameters from a Table

Our Donation Goal : Why Donate? : Donate Today! : Donate Anonymously (ਗੁਪਤ) : Our Family of Supporters
Goal this month: 500 USD, Received: 115 USD (23%)
Please Donate...
     
Related Topics...
Thread Thread Starter Forum Replies Last Post
VB Access Table creation from a SQL Pass-Through Query wnfisba Information Technology 2 28-Jul-2006 08:23 AM
SQL Pass-Through Query with User prompted parameters wnfisba Information Technology 6 28-Jul-2006 08:23 AM
RE: Passing parameters to a pass through query wnfisba Information Technology 0 28-Jul-2006 08:22 AM
User Defined Parameters for an Access Pass-Through SQL Query wnfisba Information Technology 0 28-Jul-2006 08:22 AM
SQL Pass-Through Query output to Access Table wnfisba Information Technology 4 28-Jul-2006 08:21 AM


Tags
passthrough, query, parameters, table
Reply Post New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!
  #1 (permalink)  
Old 28-Jul-2006, 08:17 AM
RoyHobbs's Avatar RoyHobbs
Guest
 
Posts: n/a
   
   
Pass-Through Query with Parameters from a Table

  Donate Today!   Email to Friend  Tell a Friend   Show Printable Version  Print   Contact sikhphilosophy.net Administraion for any Suggestions, Ideas, Feedback.  Feedback  

Register to Remove Advertisements
Hi there,

I can construct a pass-through query to access my accounting software's
database using odbc, but I have to type in the connection string parameters
such as username, password, DSN name etc to the ODBC Connect Str of the Query
Properties - for each query.

What I would like to do is have the connection string parameters (username,
password...) for the pass-through query pulled from a Table in the same mdb.
In other words, have a table with the connection string parameters then use
VBA to build the pass-through query with the connection string based on the
table supplied parameters.

I've struggled with the VBA to do this and cannot get it right. I don't have
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/10939-pass-through-query-with-parameters-table.html
a lot of experience with VBA.
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10939

Can anyone provide me with some VBA that will create a pass-through query
pulling the ODBC connection string parameters from a Table?

Thanks in advance.




Got anything to share on This Topic? Why not share your immediate thoughts/reaction with us! Login Now! or Sign Up Today! to share your views... Gurfateh!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 28-Jul-2006, 08:17 AM
Terry Kreft's Avatar Terry Kreft
Guest
 
Posts: n/a
   
   
Re: Pass-Through Query with Parameters from a Table

  Donate Today!  
A connection string is simply pairs of key/values where the key and value
are separated with an equals sign and pairs of key/values are semicolon
separated, so it's fairly easy to parse and construct.

If you make your table (tConnect) like this

Key Text (255)
Value Text (255)

You can then just fill it in e.g.

Call FillConnect and pass a valid connection string:-
Sub FillConnect(strConnect As String)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim varPairs As Variant
Dim varPair As Variant
Dim intPairs As Integer

varPairs = Split(strConnect, ";")

Set db = CurrentDb

db.Execute "DELETE * FROM tConnect"

Set rs = db.OpenRecordset("Select Key, Value From tConnect",
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10939
dbOpenDynaset)

For intPairs = LBound(varPairs) To UBound(varPairs)
varPair = Split(varPairs(intPairs), "=")
On Error Resume Next
With rs
.AddNew
.Fields(0) = varPair(0)
.Fields(1) = varPair(1)
.Update
End With
Next

rs.Close
Set rs = Nothing
Set db = Nothing
Erase varPair
Erase varPairs
End Sub

To retrieve the connection string just call ConnectFromTable

Function ConnectFromTable() As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strRet As String

Set db = CurrentDb

Set rs = db.OpenRecordset("SELECT * FROM tConnect WHERE Key <> 'ODBC'",
dbOpenDynaset)

strRet = "ODBC"
With rs
Do Until .EOF
If Len(.Fields(1) & "") < 1 Then
strRet = strRet & ";" & .Fields(0) & "="""""
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10939
Else
strRet = strRet & ";" & .Fields(0) & "=" & .Fields(1)
End If
.MoveNext
Loop
End With

rs.Close
Set rs = Nothing
Set db = Nothing

ConnectFromTable = strRet
End Function


Note: both the functions above were written for this specific post therefoe
they have not been tested with connetion strings from all providers, in fact
thy have onl been tested with a SQL Server string.


--

Terry Kreft


"RoyHobbs" wrote in message
news:06FEBEFF-26E9-4B46-AA8C-2572226D3CF0@microsoft.com...
> Hi there,
>
> I can construct a pass-through query to access my accounting software's
> database using odbc, but I have to type in the connection string

parameters
> such as username, password, DSN name etc to the ODBC Connect Str of the

Query
> Properties - for each query.
>
> What I would like to do is have the connection string parameters

(username,
> password...) for the pass-through query pulled from a Table in the same

mdb.
> In other words, have a table with the connection string parameters then

use
> VBA to build the pass-through query with the connection string based on

the
> table supplied parameters.
>
> I've struggled with the VBA to do this and cannot get it right. I don't

have
> a lot of experience with VBA.
>
> Can anyone provide me with some VBA that will create a pass-through query
> pulling the ODBC connection string parameters from a Table?
>
> Thanks in advance.
>
>



Reply With Quote
   Click Here to Donate Now!

Support Us!
Become a Promoter!
Gurfateh ji, you can become a SPN Promoter by Donating as little as $10 each month. With limited resources & high operational costs, your donations make it possible for us to deliver a quality website and spread the teachings of the Sri Guru Granth Sahib Ji, to serve & uplift humanity. Every contribution counts. Donate Generously. Gurfateh!
ReplyPost New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!

Bookmarks


(View-All Members who have read this thread : 0
There are no names to display.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Tools Search
Search:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

» Active Discussions
Occultism - Rejection in...
Today 14:04 PM
59 Replies, 2,582 Views
How does Sikhi help you...
Today 13:57 PM
24 Replies, 905 Views
Panjabi
By Ishna
Today 13:43 PM
14 Replies, 282 Views
Do you believe in...
Today 10:22 AM
195 Replies, 4,069 Views
Black Sikhs?
Today 06:33 AM
20 Replies, 5,788 Views
Man Driving Without...
Today 05:06 AM
5 Replies, 133 Views
Request for assistance...
Today 04:24 AM
8 Replies, 86 Views
Losing My Religion: Why...
Today 03:03 AM
13 Replies, 346 Views
Health Exercise And...
Today 02:10 AM
1 Replies, 89 Views
Sikh Spokesman (ਪੰਜਾਬੀ...
Today 02:10 AM
176 Replies, 4,511 Views
How Religions Change...
Today 02:07 AM
1 Replies, 105 Views
Keeping Amrit Vela
Today 01:57 AM
11 Replies, 898 Views
Rozana Reports (ਪੰਜਾਬੀ...
Today 01:52 AM
313 Replies, 7,596 Views
Parkash Guru Amar Das ji...
Yesterday 17:07 PM
3 Replies, 80 Views
Serious challenges to...
Yesterday 16:49 PM
0 Replies, 143 Views
» Books You Should Read...
Powered by vBadvanced CMPS v3.2.3
All times are GMT +6.5. The time now is 15:00 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2 Copyright © 2004-12, All Rights Reserved. Sikh Philosophy Network


Page generated in 0.35627 seconds with 32 queries
0