WHERE/Filter over Query

H

H. Martins

Hi.

This works OK:

DoCmd.OpenReport "rptTabelaVerifPReq", acViewPreview, ,
"((tblAccoes.lintTurmaKSlave)= " & cmbbxAccao.Value & ")",
acWindowNormal

Still, I was expecting that this issues a SQL Query with a WHERE
clause but it applies a filter to the Query instead. About
DoCmd.OpenReport->WhereCondition, the help says "A string expression
that's a valid SQL WHERE clause without the word WHERE"

I (supposedly) understand that the result is the same but it looks
like the first would ask for the SQL server to do the job and the
second asks the client computer do do it. It seems that the first
loads the server, the second the network and client computer.

I do not have a SQL server, I am still using MDE and separate data-
only MDB still it puzzles me a bit.

At the moment I need to make an Excel file like this:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"qryExportTurmaToExcel", "\\computer\share\dir\excel-file.xls"

It works OK but I still need to apply, to this query, a WHERE or
Filter.

Can I have some help, please?

Thanks
Henry.
 
D

DStegon via AccessMonster.com

set a variable as a string and set it equal to the text of the qry that you
are using. Then append the WHERE clause to the string and use that in your
transfer line.

QryName As String
qryString As String

QryName ="qryExportTurmaToExcel"
qryString = CurrentDb.QueryDefs(QryName).sql

qryString = qryString & "WHERE blah blah blah"
 

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