Results 1 to 6 of 6
  1. #1
    space is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2019
    Posts
    3

    Generating a Report for One Table Entry

    I'm trying to create a form in which you can search through a table based on two specific parameters (name and date), and once you find the entry you want you can press a button to generate a report from that table. My question is eventually going to regard how to generate a report with a button.



    I first created a query with just the name and date variables from the table in question. I then used a split-form to create a basic search command button which allows the user to search and select an entry based on name/date. Now that I have the correct selection, how can I go about generating a report based on that entry?

    The full table obviously has far more variables than what are included in the query, and so does anyone have advice on how to use the selected values to reverse-search the data in the table? Also, I have not had experience auto-generating reports before, and so are there any good tutorials on how to link the structure/style to a command button?

    I'd appreciate any advice you all can offer!

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I believe a split form has a property whereby you can refer to the PK field as in Me.txtNameOfPkfield to get a value from the current record, in which case you'd open a report filtered to that primary key value.

    research DoCmd.Oopen reports to learn what the parameters are so you can use the values you need, which includes the filter property and how to use it.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    space is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2019
    Posts
    3
    Thank you for the advice! Is DoCmd.Open just for opening existing reports however? After a quick search is CreateReport the appropriate command?

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    No and no. There are over 60 methods and AFAIK, CreateReport isn't one of them.

    If you want to know about all of the Methods of the DoCmd object that's a different search. On the left nav pane of this page you will also find a link to Methods pertaining to DoCmd object
    https://docs.microsoft.com/en-us/off...i/access.docmd

  5. #5
    space is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2019
    Posts
    3
    Thanks for the help Micron! I managed to get the system working, so I'll leave a brief description of my process if anyone has the same issue in future.

    1. Create a query based on your table with the terms that you want to be able to search through (i.e. names and dates)
    2. Create a split-form based on that query, and in that form use a command button to create a basic search feature (tutorials are available on youtube)
    3. Create another query from your data table with all of the relevant issue from your report, but in the Criteria section of your Name section use Criteria: Forms![Insert name of form]![Insert variable name]
    4. Create a report based on the previous query and structure it as you wish
    5. Create a button in your split-form called "Generate Report." Give this button a visual basic code that will open the relevant query and report. This will export the final report to a PDF you can then save wherever. I included my specific code below



    Private Sub CreateReport_Click()


    DoCmd.OpenQuery "Individual Data"
    DoCmd.OpenReport ("Individual Report")


    End Sub

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    thanks for posting your solution (not that I follow it entirely). I'm not grasping the need for opening a query that the report is based on, nor am I seeing how that code outputs a report as a pdf. Oh well, as long as you're happy.

    Good luck with your db.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Need assistance with generating a report
    By HarryZ in forum Reports
    Replies: 6
    Last Post: 05-02-2019, 11:47 PM
  2. Generating A Count In A Report
    By McArthurGDM in forum Reports
    Replies: 3
    Last Post: 04-15-2015, 11:26 AM
  3. Replies: 1
    Last Post: 04-01-2013, 02:18 PM
  4. Generating Part Numbers From Field Entry
    By JMac in forum Database Design
    Replies: 10
    Last Post: 02-20-2012, 07:12 PM
  5. Help on Generating a Report!
    By ETCallHome in forum Reports
    Replies: 10
    Last Post: 06-22-2011, 01:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums