Results 1 to 9 of 9
  1. #1
    ryanwales is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    27

    Making report show data from form and subform from print button

    Hi guys/girls,

    Before, I had a quote form that would only allow the addition of one product to each quote. the following VBA allowed fields from the form to appear in their corresponding fields in a report:

    Private Sub cmdPrint_Click()
    Dim strWhere As String

    If Me.Dirty Then 'Save any edits.
    Me.Dirty = False
    End If

    If Me.NewRecord Then 'Check there is a record to print
    MsgBox "Select a record to print"
    Else


    strWhere = "[ID] = " & Me.[ID]
    DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
    End If
    End Sub


    I attempted to use this on my newest form that allows multiple products to each quote and while the report appears with no errors, nothing shows up in the fields.
    Can anybody shed any light on this?

    Thanks in advance

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Change
    Code:
    strWhere = "[ID] = " & Me.[ID]
    to

    Code:
    strWhere = "[ID] = Forms!YourFormName!ID"

  3. #3
    ryanwales is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    27
    Thanks for getting in touch so quickly. Unfortunately (even though once again there are no errors present) the same problem is happening, nothing appears in the fields!
    What could be causing this?

    Thank you

  4. #4
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Suggest you post your db to the forum and let us have a look at it.

    Alan

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Alan, still need to concatenate the value from form control. However, changing code from the Me qualifier to the explicit form name should not make any difference. Something else is wrong. I suspect has to do with RecordSource. Better post database for analysis.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Better post database for analysis.
    I Agree with this. I pulled the Where statement from a report code I use and didn't have to use concatenation, but there is something fishy here.

  7. #7
    ryanwales is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    27
    Hi both, embarrassingly i believe it was a problem with the report query. I hadn't linked the query with the form as such and as a result it was showing results from the query (where there were none..hence it being blank -doh!). Sorry for wasting your time on that one.

    I still have a problem showing multiple values however. When I click print report, the products come up in separate sections with recurring details such as quote ID, total price ect.

    QuoteID, customer, subtotal, tax, shipping and Quotetotal only need to come up once, whereas the product name, qty, listprice and total would ideally be underneath eactother.

    How do i go about it?

    Thank you both

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Depends. If you are printing a single quote for one customer put the QuoteID, customer, subototal, tax, shipping and quotetotal items in header or footer sections.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    ryanwales is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    27
    Quote Originally Posted by June7 View Post
    Depends. If you are printing a single quote for one customer put the QuoteID, customer, subototal, tax, shipping and quotetotal items in header or footer sections.
    Yes, it'll be a single quote per customer that could have more than one product on it.

    Thanks, I'll try it now!

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

Similar Threads

  1. Show only current record in report from form/subform
    By stelioshania in forum Reports
    Replies: 0
    Last Post: 03-02-2011, 02:19 PM
  2. Replies: 0
    Last Post: 02-22-2011, 05:04 AM
  3. Subform will not show data
    By Brian62 in forum Forms
    Replies: 2
    Last Post: 02-19-2010, 10:43 AM
  4. Replies: 3
    Last Post: 10-16-2009, 07:54 AM
  5. Error in Print Report Button
    By Robert M in forum Reports
    Replies: 16
    Last Post: 09-23-2009, 03:08 PM

Tags for this Thread

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