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

2019-08-03 20:59发布

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.

2条回答
Summer. ? 凉城
2楼-- · 2019-08-03 21:41

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.

查看更多
Melony?
3楼-- · 2019-08-03 21:54

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
查看更多
登录 后发表回答