Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4551368
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:37:33+00:00 2026-05-21T16:37:33+00:00

I have a form that contains multiple partners that share a pool. The partners

  • 0

I have a form that contains multiple partners that share a “pool”. The partners are listed on a subform. After I’m done entering the information, I want a button to run a report for each of the partners with their specific information. But since it’s multiple partners and I need one report for each (which I then want to email), I want to use a Loop to go through each of the partners.

EDIT1: Added entire code for review. I do have Option Explicit in and I have compiled it as well.

Private Sub btn_Run_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String

strSQL = "Select * FROM Cobind_qryReport WHERE PartPoolName = """ & Me.TopLvlPoolName & """"
Debug.Print "strSQL: " & strSQL

Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL)

On Error GoTo Err_PO_Click

If MsgBox("Do you wish to issue the cobind invites?", vbYesNo + vbQuestion, "Confirmation Required") = vbYes Then
rs.MoveFirst
Do While rs.EOF = False
DoCmd.OutputTo acOutputReport, "Cobind_rptMain", acFormatPDF,_
   "K:\OB MS Admin\Postage\CoBind Opportunities\Sent Invites\" _
   & rs!CatCode & "_" & rs!PartPoolName "Cobind Invite_" & _
Format(Now(), "mmddyy") & ".pdf"
DoCmd.SendObject acSendReport, "Cobind_rptMain", acFormatPDF, ,_
, , " Cobind Invite", "Please find the cobind invite attached._
 Response is needed by " & [RSVP] & ". Thank you.", True
rs.MoveNext
Loop
End If

Exit_PO_Click:
MsgBox ("It didn't work")
rs.Close
Set rs = Nothing
Set db = Nothing
Exit Sub

Err_PO_Click:
MsgBox Err.Description
Resume Exit_PO_Click
End Sub

This should allow me to create a report for each record in my query, save it to my server, then open an email to send it out. Right now, it appears that the [PartPoolName] is hanging up the code because I’m getting a “Microsoft Office Access can’t find the field “|” referred to in your expression.” If I take out the [PartPoolName], it’ll create a PDF with four pages (each page showing a partner), where I want to end up with four separate PDFs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T16:37:34+00:00Added an answer on May 21, 2026 at 4:37 pm

    The first thing you should do is add Option Explicit to the Declarations section of your module.

    Then, from the Visual Basic editor’s main menu, select Debug->Compile [your project name here]

    Fix all the problems the compiler complains about. I suspect one of the compiler’s first complaints may be triggered by this section of your code:

    rs.MoveFirst
    
    Do While Recordset.EOF = False
    

    Do you have two recordset objects open, or one?

    After you fix everything the compiler complains about, try your revised code.

    If you get runtime errors, show us the exact error message and which code line is highlighted.

    If the part of your code you haven’t shown us includes an error hander, you can disable that error handler like so:

    'On Error GoTo Err_PO_Click
    

    Error handlers are great for production to shield users from errors. However, during development you really need to be able to identify which code line causes the error.

    Alternatively, you can leave your error handler active and select Tools->Options from the editor’s main menu. In the Options dialog, select the General tab, then select the “Break on All Errors” radio button and click OK. You can switch that option back to “Break on Unhandled Errors” after you finish your testing.

    Update: You wrote: Right now, it appears that the [PartPoolName] is hanging up the code because I’m getting a “Microsoft Office Access can’t find the field “|” referred to in your expression.”

    What is [PartPoolName]? If it’s a field in the recordset, you can reference its value as rs!PartPoolName If it’s something else, perhaps a global variable, give us more information about it.

    Update2: Whenever your current code completes without error, you will hit this:

    Exit_PO_Click:
    MsgBox ("It didn't work")
    

    Can that be right?

    Update3: This OutputTo statement is your issue now, right?

    DoCmd.OutputTo acOutputReport, "Cobind_rptMain", acFormatPDF,_
       "K:\OB MS Admin\Postage\CoBind Opportunities\Sent Invites\" & _
       "Cobind Invite_" & Format(Now(), "mmddyy") & ".pdf"
    

    Cobind_rptMain is a report. It has a RowSource for its data. You’re calling OutputTo with that report 4 times (once for each of the 4 rows in the recordset). Yet you expect 4 different versions of that report … a separate report for each PartPoolName value?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form element that contains multiple lines of inputs. Think of each
i have a form that contains 3 File inputs.i want to send it via
I have a content submission form that contains multiple fields for input, all of
I have a form that contains a GridView control which is databound to an
I have a form that contains a bunch of checkboxes. Before submitting the form,
I have asp.net form that contains fields. When I access this window, my javascript
I have an asp.net text form that contains numerous decimal fields that are optional.
I have a form that has a few similar controls and the parent contains
I would like to have an aspx page that contains something like.... <form id=form1
I have a form JSP web page, this form contains multiple instances of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.