Use MS Query in VBA to only get a SQL statement
Not to actually build a query - I know of no way of just calling up the query
wizard or design screen without actually having Access running; but you can
(as I mentioned) keep Access hidden from the user up to the point where the
user needs to see the dialogs. And all of your code to control this is in
your Excel VBA project. With a few tricks it is even possible to keep the
main Access screen hidden, if that is a distraction (that is beyond the scope
of a quick answer here, but resizing windows and/or the use of Windows API
calls for Topmost window are handy tricks!). So: from Excel, you start
Access and keep it hidden - users won't even know it is there - until you
need it, then you pop it up, get their input, and immediately hide it again.
From the user's end it would appear the same as if only the query builder
popped up.
"RB Smissaert" wrote:
Yes, but I would like to all automate this from Excel in VBA.
So I don't want to start up Access. Could I just use the Access dialog
without actually showing Access via OLE automation?
RBS
"Al" wrote in message
...
The optimal place to get your SQL statements is from MS Access as Access
will
allow you to have a where condition on a field not included in the Select
statement. After creating your Query using the Access GUI, you can switch
to
SQL view and simply copy and paste the query into your Excel VBA module.
"RB Smissaert" wrote:
I wonder if this were possible:
Use MS Query to construct a SQL statement and use the statement in VBA
code
(ADO, ODBC connecting to Interbase), but don't let it run the statement.
So just use the MS Query as a SQL wizard, incorporated in VBA code.
Doing this would save a lot of coding to get a similar wizard, although
it
shouldn't be too difficult either.
One drawback I can see is that MS Query won't let you do a WHERE
condition
on a field that is not in the SELECT
clause. The good thing though is that it will automatically add any
joins,
although I am not sure how it will handle
joins that are not inner joins.
Hope this explains it clear enough and thanks for any advice.
RBS
|