Problem with ORDER Clause and ODC Datasource

P

Pius Graber

I'm using the following Code in MSAccess 2002:

WordApp.ActiveDocument.MailMerge.OpenDataSource Name:= _
"J:\qWord.odc" _
, ConfirmConversions:=False, ReadOnly:=False,
LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="",
Revert:=False, _
Format:=wdOpenFormatAuto, Connection:="",
SQLStatement:="SELECT * FROM [qWord999]", SQLStatement1 _
:="", SubType:=wdMergeSubTypeOther

with the following part in the qWord.odc (to SQL Server)

<odc:CommandText>&quot;MyDatabase&quot;.&quot;dbo&quot;.&quot;qWordTemplate&quot;</odc:CommandText>

This works fine.

When I change the SQL-Statement to

"SELECT * FROM [qWord999] ORDER BY P_Name"

I get an error "Unable to Open Datasouce"

Can someone help please?

Thank you
 
P

Peter Jamieson

I tried replicating this problem (with different db names etc.) but with
equivalent syntax had no problems opening the data source. Incidentally, I
suspect you only need the Name and SQLStatement parameters in this case.

The only thing I can think of is that SQL Server might not be able to sort
on P_Name for some reason. Are you able to ORDER BY using any other column
in the table?

--
Peter Jamieson - Word MVP
Word MVP web site http://word.mvps.org/

Pius Graber said:
I'm using the following Code in MSAccess 2002:

WordApp.ActiveDocument.MailMerge.OpenDataSource Name:= _
"J:\qWord.odc" _
, ConfirmConversions:=False, ReadOnly:=False,
LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="",
Revert:=False, _
Format:=wdOpenFormatAuto, Connection:="",
SQLStatement:="SELECT * FROM [qWord999]", SQLStatement1 _
:="", SubType:=wdMergeSubTypeOther

with the following part in the qWord.odc (to SQL Server)
This works fine.

When I change the SQL-Statement to

"SELECT * FROM [qWord999] ORDER BY P_Name"

I get an error "Unable to Open Datasouce"

Can someone help please?

Thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top