Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Hommer
Aged Yak Warrior
808 Posts |
Posted - 2005-12-29 : 11:48:58
|
I need to dynamically add a filter to a qry from a report's open event in ac97. My last line of code listed below returns "item not found in this collection run_time error 3265. I would see the field name in the debug window. What is the right syntax? Thanks!Private Sub Report_Open(Cancel As Integer)Dim db As DatabaseDim qrydef As QueryDefSet db = currentdb()Set qrydef = db.QueryDefs("qryCustInvoice")qrydef("INVOICE_NO") = "535706" |
|
Hommer
Aged Yak Warrior
808 Posts |
Posted - 2006-01-26 : 13:43:18
|
I have found a tricky way to make it worked. Basically, I have to prebuild a second passthrough query. The original one is the real one that will tie to the report, and the dummy one acts like a "template" with exact sql from the origin but also has a hard coded whereClause. On run time, I use QueryDef to read from the template query's sql statement and replace the whereClause with the real one then assign it to the first query before all the data binding codes get run.The ugly part is that it has to be a passthrough even though it will never get run, otherwise Access will check the syntax and would not let you save the sql under a regular query. |
 |
|
|
|
|