Access:How can I generate a report of a recordset?

你。 提交于 2020-01-05 08:42:50

问题


How can I generate a report in access with the data from a recordset (instead of a query or table). I have updates to the recordset that also must be shown in the report.


回答1:


From Access Web you can use the "name" property of a recordset. You resulting code would look something like this:

In the report

Private Sub Report_Open(Cancel As Integer)
    Me.RecordSource = gMyRecordSet.Name
End Sub

In the calling object (module, form, etc.)

Public gMyRecordSet As Recordset
'...
Public Sub callMyReport()
    '...
    Set gMyRecordSet = CurrentDb.OpenRecordset("Select * " & _
                                               "from foo " & _
                                               "where bar='yaddah'")
    DoCmd.OpenReport "myReport", acViewPreview  
    '...
    gMyRecordSet.Close  
    Set gMyRecordSet = Nothing
    '...
End Sub



回答2:


Please explain in more detail. For example, do you wish to show what the field was and what it is now? If so, you will need an audit trail. Here is an example from Microsoft: http://support.microsoft.com/kb/q197592/

What do you mean by report? If you mean a printed paper document, Access has a good report builder. If you mean you wish to view the data, you can use a form. If you are unfamilar with building reports and forms, there are wizards.

It is always wise to study the Northwind sample database that ships with every version of Access.



来源:https://stackoverflow.com/questions/242504/accesshow-can-i-generate-a-report-of-a-recordset

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