Results 1 to 2 of 2

Thread: Access Report and VBA

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2004
    Posts
    50

    Access Report and VBA

    Hi Guys,

    I have a report that is already created in Microsoft Access. What I need to do is create some VBA code that will using some calculations, produce an SQL statement and then get me a set of data. I then want to use that set of data in the report.

    I need to be able to use VBA because the information needs to be calculated to make the query.

    Once I have my data set using SQL (i can do this) how do I go about using it in the report.

    Shane

  2. #2
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Access Report and VBA

    Is this from inside Access??

    You can set the record source of the report by opening it is design view, save it and then re-open the report to show or print..

    VB Code:
    1. 'open the report in design mode but hidden
    2.   DoCmd.OpenReport "ReportName", acViewDesign,,,acHidden
    3.   Reports("ReportName").RecordSource = "Name Of Query or SQL String"
    4.   DoCmd.Close acReport, "ReportName", acSaveYes
    5.   'now open the report in print preview
    6.   DoCmd.OpenReport "ReportName", acViewPreview
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width