Access: Print selected records form query

2019-08-28 02:30发布

I really don't know how to start this. I have a report, that takes records from a query. The query itself takes the records from a table. Now I want to be able to select the records in the query by the id manually. But there is no connection between the records, so I can't say 'give me all records between id x and y'. Also, there is not the count of records always changing. I want a user to be able to say: 'okay, I need to print all the data of these x ids'. how can I archive this?

2条回答
三岁会撩人
2楼-- · 2019-08-28 02:41

You could populate a multiselect listbox from the same record source as the report, and then use the selected records from that to drive the actual report data.

You would probably want to build a PK IN(1,3,99,104...) style criteria by looping through the selected items from the listbox.

查看更多
beautiful°
3楼-- · 2019-08-28 02:43

you can create the object using Querydef and used this to change your query at runtime based on the user slected criteria.

try like this

Dim query_1 as string

query_1 = "Select * from Table1 where ID  = 'Your ID'"

CurrentDb.QueryDefs("Report_Query").sql = query_1 

than open the report or make pdf ..

查看更多
登录 后发表回答