Access: Print selected records form query

99封情书 提交于 2019-12-11 16:04:49

问题


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?


回答1:


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 ..




回答2:


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.



来源:https://stackoverflow.com/questions/50913360/access-print-selected-records-form-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!