none
Print current record within a form RRS feed

  • Question

  • In my form I've got a subform and I'm wanting to have a command button to do a print preview on the current record I'm on in the form/subform that shows some fields form the form and records from the subform. I've got it setup and it will display but I get prompted to enter the Primary key of the form before it will display.  I'd imagine the reference I have is setup wrong.  Form/subform is one to many relationship and both the form/subform linking fields are called RqmtID.

    How do I clear this prompt and just have the report display without being prompted?  Or better yet, just starting from scratch how can I make this work?


    TAK

    Friday, August 7, 2015 2:34 PM

Answers

  • If RqmtID is part of your record source on the main form, then I would say that you don't need to add an additional control for it. 

    As for your report, I don't think that it's necessary for you to have your record source query reliant on the form.  So remove the where clause.  It would be better if you open your report and set the report's criteria in the DoCmd statement. 

    DoCmd.OpenReport "MyReport",,,"RqmtID=" & Me.RqmtID

    • Marked as answer by taking Friday, August 7, 2015 4:53 PM
    Friday, August 7, 2015 4:21 PM

All replies

  • I can only assume that you are using a query for your report.  Given your description, it sounds like you have a field that is not recognized in your query that would otherwise refer to the RqmtID.  Check for any spelling mistakes.

    It might be helpful if you post your SQL.

    Friday, August 7, 2015 2:42 PM
  • Yes, I'm using a query for the report.  This is what I've got in the query Criteria as a Where clause for RqmtID of the parent form field: 

    [Forms]![frmRqmtMbrEntry]![RqmtID]

    Is this format correct?  I'd assume it is because at least it does popup to enter the RqmtID when I click the print preview button on the form/subform and will display the form/subform report I'm current on after I enter it. 

    The frmRqmtMbrEntry part is the name of the parent form but I've tried using the subform name reference as well with the same results.  Shouldn't the RqmtID be the reference to the parent form?  Do I need to have the RqmtID field actually in the parent form and subform?


    TAK

    Friday, August 7, 2015 2:56 PM
  • Hi,

    Re: "Do I need to have the RqmtID field actually in the parent form and subform?"

    You might try adding it to the parent form, at least.

    Friday, August 7, 2015 4:12 PM
  • If RqmtID is part of your record source on the main form, then I would say that you don't need to add an additional control for it. 

    As for your report, I don't think that it's necessary for you to have your record source query reliant on the form.  So remove the where clause.  It would be better if you open your report and set the report's criteria in the DoCmd statement. 

    DoCmd.OpenReport "MyReport",,,"RqmtID=" & Me.RqmtID

    • Marked as answer by taking Friday, August 7, 2015 4:53 PM
    Friday, August 7, 2015 4:21 PM
  • Looks like that did the trick.  I had the command button (that opens the report) as a macro in "On Click" but changed it to code and put the following expression in it:

    DoCmd.OpenReport "rptRequirementMembers", acViewPreview, , "Rqmttbl.RqmtID=" & Me.RqmtID


    TAK

    Friday, August 7, 2015 4:53 PM
  • I tried that as well but got the same results.  I ended up changing the command button "On Click" from a macro to code and that ended up working:  

    DoCmd.OpenReport "rptRequirementMembers", acViewPreview, , "Rqmttbl.RqmtID=" & Me.RqmtID


    TAK

    Friday, August 7, 2015 4:55 PM
  • Glad to hear it worked out for you...
    Friday, August 7, 2015 5:01 PM