Results 1 to 13 of 13
  1. #1
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133

    Subform does not run reports, form view works fine?

    Hello everyone,



    I have created a form that prints reports based on date, due to the privacy of the db I cannot upload but I am willing to answer any questions you may have.

    The form brings my reports just fine and i named the normal form frmreportsprint and the sub is sbformreportsprint. the code within the form does use the forms name to run for certain data.. but with the main form being the control source I don't understand why it wont execute, there error I get just says "Unknown" with no other information when I try to use the subform.

    any suggestions?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The syntax for referencing the current Form is different if you run the form as a sub form. Could that be the source of your issue?
    http://access.mvps.org/access/forms/frm0031.htm

  3. #3
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    So with any query or report that references back to the form name itself needs to be tweaked like Me.frmreportsprint.sbfrmreportsprint to identify the control?

    Code:
    AND 
    timestamp Between #" & [Forms]![frmreportsprint]![txtStart] & "# And #" & [Forms]![frmreportsprint]![txtEnd] & "#")
    Code:
    AND 
    timestamp Between #" & [Forms]![frmreportsprint]![sbfrmreportsprint]![txtStart] & "# And #" & [Forms]![frmreportsprint]![sbfrmreportsprint]![txtEnd] & "#")
    like so?

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The syntax actually needs to go through the FORMS collection: Forms!MainFormName!SubFormControlName.FORM!ControlName

  5. #5
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    I appreciate your help, could you elaborate "forms collection", all my code essentially is sitting on the reports and querys. on the form itself the buttons to open them is just a simple macro open. I'm far from an expert more like a blind kid in a candy store.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Sorry! That simply means the syntax begins with FORMS! as do the examples you posted in post #3.

  7. #7
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    I see what your saying so this would apply to every report/query with a reference to the main form, essentially changing all of them individually? I only ask because it's a lot of reports haha!
    Click image for larger version. 

Name:	Capture.PNG 
Views:	4 
Size:	122.9 KB 
ID:	29024
    This is where I have the subform, the only thing the cmd.buttons do is Load the "reports" in report view, the code for the reports to gather the db info runs within the reports and queries, so can I change the cmd.button from macro to code and just link the cmd.buttons that way, it seems like it might be less tedious that changing all the reports and queries. even though it is just a copy paste job really.

    Code:
    AND timestamp Between #" & [Forms]![frmshippingprint]![sbfrmshippingprint.FORM]![txtStart] & "# And #" & [Forms]![frmshippingprint]![sbfrmshippingprint.FORM]![txtEnd] & "#")

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I believe the answer to your question is yes. I don't use macros so I would have to see the code to have a more definitive answer.

  9. #9
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    I actually got the error to surface:
    Click image for larger version. 

Name:	Capture.PNG 
Views:	4 
Size:	20.6 KB 
ID:	29025

    This was after just trying to redirect the queries and reports like I pasted above, so I definitely think removing the macros is going to be my best bet, let me give one of them a shot and let you know how it goes..

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Cool! I'll be around.

  11. #11
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    I guess I'm not sure where to reference it here after i converted my Macros:

    Code:
    '------------------------------------------------------------' Command15_Click
    '
    '------------------------------------------------------------
    Private Sub Command15_Click()
    On Error GoTo Command15_Click_Err
    
    
        ' _AXL:<?xml version="1.0" encoding="UTF-16" standalone="no"?>
        ' <UserInterfaceMacro For="Command14" Event="OnClick" xmlns="http://schemas.microsoft.com/office/accessservices/2009/11/application"><Statements><Action Name="OpenReport"><Argument Name="Report
        ' _AXL:Name">Reported_Quality</Argument><Argument Name="View">Print Preview</Argument></Action></Statements></UserInterfaceMacro>
        DoCmd.OpenReport "Reported_UW", acViewPreview, "", "", acNormal
    
    
    
    
    Command15_Click_Exit:
        Exit Sub
    
    
    Command15_Click_Err:
        MsgBox Error$
        Resume Command15_Click_Exit
    
    
    End Sub
    The only other things I can think of would be the txtstart and end I mean those point right to the main form, I tried

    Code:
    AND timestamp Between #" & [Forms]![frmshippingprint]![sbfrmshippingprint.FORM]![txtStart] & "# And #" & [Forms]![frmshippingprint]![sbfrmshippingprint.FORM]![txtEnd] & "#")
    Receiving the same error. "Unknown"

  12. #12
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    Haha, I am dim sometimes, frmshippingprint was not the main form the sub form ws on just the main form of the sub form xD once i referenced as you described with the frmhome(my main form) it work just fine thank you so much!

    Code:
    [frmhome]![sbfrmshippingprint]

  13. #13
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Outstanding! Thanks for the update and marking the thread as Solved.

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

Similar Threads

  1. Replies: 5
    Last Post: 12-15-2015, 04:01 PM
  2. Replies: 7
    Last Post: 08-16-2015, 10:10 PM
  3. Replies: 2
    Last Post: 12-07-2014, 10:03 PM
  4. Replies: 1
    Last Post: 11-14-2014, 05:12 PM
  5. Replies: 6
    Last Post: 10-15-2014, 02:45 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