none
can i have as the data source for a report a string. NOT part of a table, qry, recordset? RRS feed

  • Question

  • I have a string assembled from various controls Using their after update events. Based on what user selects.

    trying to make that string as the recordsource for a report.

    I have been creating reports based on tables, queries or DAO.recordsets for years.

    I haven't found a way to base a access 2013 win7 64bit report on ONLY a string.

    the only way I have figured out so far is to

    1. have a table with only one record in the table.

    2. run code to delete all records in table.

    3. run code to add the string to the table. ( NOW has only one record, a record that has the sting I want to show in the report)

    4. run code to show report based on the table.

    Repeat lines 2 thru 4 each time the string changes.

    Seems got to be a better way to do this.


    Mark J

    Friday, December 30, 2016 10:59 AM

Answers

  • You could pass the string as OpenArgs to the report

    DoCmd.OpenReport "TheReport", acViewPreview, , , , TheString
    

    then in the Detail_Format event, assign it to a text box:

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Me!TheTextBox = Me.OpenArgs
    End Sub
    
    

    Matthias Kläy, Kläy Computing AG

    • Marked as answer by PuzzledByWord Friday, December 30, 2016 1:52 PM
    Friday, December 30, 2016 12:43 PM

All replies

  • You could pass the string as OpenArgs to the report

    DoCmd.OpenReport "TheReport", acViewPreview, , , , TheString
    

    then in the Detail_Format event, assign it to a text box:

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Me!TheTextBox = Me.OpenArgs
    End Sub
    
    

    Matthias Kläy, Kläy Computing AG

    • Marked as answer by PuzzledByWord Friday, December 30, 2016 1:52 PM
    Friday, December 30, 2016 12:43 PM
  • Matthias Klay,

    Thanks so very much.

    I had hoped the answer would be so simple and easy to do.

    Much better way than I had come up with.

    It works great, and fast.

    It has saved me lots of time.


    Mark J

    Friday, December 30, 2016 1:52 PM