Access 2007: Dynamic SQL to be run when opening a report

Posted by blockcipher on Stack Overflow See other posts from Stack Overflow or by blockcipher
Published on 2010-04-15T14:22:00Z Indexed on 2010/04/15 14:33 UTC
Read the original article Hit count: 224

Filed under:

I'm trying to have some SQL execute when I open a report. This works fine when I try to match on a column that's an integer with an integer, but when I try to match on a "text" column, it keeps popping up a dialog asking for what you want to filter on.

Here's a somple query:

select person_phone_numbers.person_id from person_phone_numbers where phone_number = '444-444-4444'

This is actually a sub-query I'm trying to use, but this is where the problem is. If I change it to this it works fine:

select person_phone_numbers.person_id from person_phone_numbers where phone_id = 2

I put this in the OnOpen event and I'm assigning it to Me.RecordSource if that makes a difference. My goal here is to have a form accept query parameter(s) and have it open a report with the results.

Any thoughts on why it wants to ask for a parameter vs. just running the query the way I have it?

© Stack Overflow or respective owner

Related posts about ms-access-2007