If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Creating an Access Query Programmatically using ADO

Hi Dan,

I have several of your books...and let me say "thanks...they are the best".

Now, I would like to know how I might be able to create an Access2000 querydef
using the ADO 2.1 library.

It seems that one might have to use ADOD.Command objects to pass a name,
and the sql text to actually store the query permanently in the Access database.
Only, nothing I have tried seems to get the job done.

Re: Creating an Access Query Programmatically using ADO

Dee:

Sorry, I'm not a database guy. I've always created my queries using Access and used
them from ADO.
I would suggest exploring MSDN - there must be an example of that somewhere.

Dan

Dee Lewis wrote:
> Hi Dan,
>
> I have several of your books...and let me say "thanks...they are the best".
>
> Now, I would like to know how I might be able to create an Access2000 querydef
> using the ADO 2.1 library.
>
> It seems that one might have to use ADOD.Command objects to pass a name,
> and the sql text to actually store the query permanently in the Access database.
> Only, nothing I have tried seems to get the job done.
>
> I try:
>
> Sub SaveQry(strName As String, strSQL As String)
> On Error GoTo ErrH
>
> Set objCmd = New ADODB.Command
> objCmd.CommandText = strSQL
> Set objCat.Procedures(strName).Command = objCmd <---- Error Here
>
> Set objCmd = Nothing
> Exit Sub
> ErrH:
> MsgBox Err.Description
> Exit Sub
>
> End Sub
>
> .the result is an error on the Set objCat.Procedures line.
>
> Help!!! Please.
>
> Thanks in advance, and kkep up the great work.
>
> Dee Lewis