starspike


I've used the DoCmd.OPenReport with the WHERE-clause for some time now. My reports where all based upon a table in my database.
But now I have a report that's not based on a table but on a query. The problem is that my report opens, but it just doens't seem to hold my WHERE-clause in account.

For example:

I have two (linked) tables:
Locations (two fields: LocationID & LocationName)
Transactions (lots of fields, but one is the Location through the LocationID)
Now I wanna show the Location NAME in my report and not the ID, so a query was necessary. All well up until now, but the problem is that I want my application to only show the transactions for this year, so I have something like:

Code Snippet

DoCmd.OpenReport "rptTransactions",acViewPreview,,"Year = " & intYear,acWindowNormal


But it never filters on Year...
Any thought ons this would be greatly appreciated.

after edit: nobody



Re: DoCmd.OpenReport for report based on a query

RhysDavies


Hi mate - your code treats yor field 'year' as a text field so it may be that it is not compatible with the 'intyear' value - try converting 'intyear' to text maybe

DoCmd.OpenReport "rptTransactions",acViewPreview,,"Year = " & Cstr(intYear) & "'"






Re: DoCmd.OpenReport for report based on a query

starspike

RhysDavies wrote:

Hi mate - your code treats yor field 'year' as a text field so it may be that it is not compatible with the 'intyear' value - try converting 'intyear' to text maybe

DoCmd.OpenReport "rptTransactions",acViewPreview,,"Year = " & Cstr(intYear) & "'"



Thank you for the response: it worked as a charm!!! Smile