[AccessD] weird query def

Gustav Brock gustav at cactus.dk
Wed Jul 2 04:23:10 CDT 2003


Hi Mark

Thanks Mark!

But this was my suspicion:

> 'References set to .. db1.mdb (where the query and function are)

That's the trick.
If you do so, I guess DAO will work fine as well.

/gustav


> Sorry, I should have done it last night. I'd had a few beers and just
> zipped up the mdb's and sent them to John (wasn't sure about sending
> attachments to the list). Here's the code then.... It's simple and a bit
> rough, just to show it could be done.

> In db1.mdb there is a simple function that multiplies one value by
> another. There is also a query which uses the function as column "X"
> (could be anything).

> In db2.mdb...

> Sub mTest()
> 'References set to ADO 2.1 and to db1.mdb (where the query and function
> are)
>     Dim rs As ADODB.Recordset
>     Dim strCon As String
>     Dim fld As ADODB.Field
    
>     strCon = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data
> Source=E:\Data\db1.mdb"

>     Set rs = New ADODB.Recordset
    
>     rs.Open "SELECT * FROM Query1", strCon
>         'Note: you should set the where clause to return
>         'no records - make it quicker, data not needed anyway
>     For Each fld In rs.Fields
>         Debug.Print fld.Name
>     Next
    
>     Set rs = Nothing
>     strCon = ""
    
> End Sub

> Cheers

> Mark

> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
> Sent: 02 July 2003 09:11
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] weird query def


> Hi Mark

> OK. Thanks but I don't have a specific need right now. It was out of
> curiosity - it would be nice to have look. Couldn't you just post the
> relevant code here - also for the benefice of others following this
> thread?



More information about the AccessD mailing list