SQL parsing problem

richard luft

Registered User.
Local time
Today, 05:56
Joined
Jun 4, 2004
Messages
63
Hope someone can help with the following:
I'm using Acess2 and am trying to run the following query in a sub function.
MySQL = "SELECT TOP 1 (DMin("[Date_From]","services","[clientID#] = a and [payer] = b"))
MySQL = MySQL & "AS x FROM SERVICES;"
When this line is compiled, I get errmsg of "Expected: end-of-statement", with [Date_From] highlighted.
Note that this SQL runs fine in a query window.
What's wrong?
TIA, Richard
 
I think you need to add a quote " at the end of the first MySql line.
 
Richard,

You can't get a TOP 1 from a DMin function. That's why its a DMin. Could
you expect it to choose if there's a tie?

The SQL fragment that you are looking for is something like this:

Code:
MySQL = "SELECT * ' & _
        "From   services " & _
        "Where [clientID#] = '" & a & "' And " & _
        "      [payer] = '" & Me.b & "'"

but it has to be in the right "environment".

Need more info here ...

Wayne
 

Users who are viewing this thread

Back
Top Bottom