Re: Statement parameter in Mailmerge.OpenDataSource



You can certainly pass an SQL SELECT statement with a WHERE clause. Getting
the syntax right can be difficult, as you have discovered. What I find
generally works is
a. quoting table and column names. I think it is clearer to use `` or []
rather than "" but it may be less standard these days
b. aliasing tables - even when aliasing should not be syntactiaclly
required - and always using the alias names when referencing individual
columns
c. using single quotes ' ' as text literal delimiters
e.g. (not tested - you'll need to play around to check)

SELECT [MV].* FROM [MyView] MV WHERE [MV].[MyColumn] = 'abc'

You may also be able to pass a call to a Transact-SQL procedure using the
old ODBC escape syntax which looks something like

{ call functionname(p1,p2) }

You may be able to find out more about that in SQL Server Books Online.
However, I have had a mixed experience using that approach in the past
because, for example, procedures that return multiple results do not seem to
work.

Peter Jamieson

"Christof Nordiek" <cn@xxxxxxxxx> wrote in message
news:ef6yr$WSFHA.3664@xxxxxxxxxxxxxxxxxxxxxxx
> i'm trying to make some MailMerge by automating word2003.
> If i call MailMerge.OpenDataSource, what can i pass for the Satement
> Parameter?
> For Connectioninformation i'm using a *.odc file, wich connects to a
> SQL-Server.
> The name of the odc-file i pass as the Name parameter.
>
> when I try
> SELECT * FROM MyView
> it fails.
>
> SELECT * FROM "MyView"
> succeeds.
>
> Also passing the name of the view suceeds only with quotationmarks
>
> What i'm trying to do is, passing a statement calling a table-valued
> Function with parameters and/or a statement with a where clause containing
> Filterconditions.
>
> Does anyone know, how to do this?
>
> Thanks
>
>
>


.



Relevant Pages

  • Re: SQL syntax over a network
    ... > SQL you mean copied from the SQL view of a Query, ... > Syntax error in FROM clause ... But that doesn't match the syntax that you originally said it did; ... Dirk Goldgar, MS Access MVP ...
    (microsoft.public.access.modulesdaovba)
  • Re: Joins over the equality sign
    ... Logically the FROM clause is processed first. ... I agree that if you *want* a Cartesian product, then use the new syntax and CROSS JOIN. ... Tibor Karaszi, SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: MSACCESS 2003 CREATE PROC
    ... The query is incorrect in the GROUP BY clause. ... syntax instead of JET's syntax (Using an aggregate alias in an ... CurrentProject.Connection.Execute SQL ...
    (comp.databases.ms-access)
  • Re: Programming for a Dynamic Where clause
    ... diffcult to check the SQL syntax around the dates. ... When you're done building the SQL string use debug.print and pate the ... Tim. ... >> clause is ...
    (microsoft.public.excel.programming)
  • Evaluating a datalist item using a function
    ... As I read in the records from the SQL into my datalist I want to be ... The problem is I haven't been able to find away passing the ... ammendments back to the datalist. ... So can someone help with the syntax with this and also how to find the ...
    (microsoft.public.dotnet.framework.adonet)