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 9016459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:00:06+00:00 2026-06-16T04:00:06+00:00

Needing help understanding the context behind the DoCmd.OpenReport function. I have a button on

  • 0

Needing help understanding the context behind the DoCmd.OpenReport function. I have a button on a form that generated a report with all of the records in my database tables. I want the report to only generate based on the information displayed in the Form. I have used the wizard to add a command button to my form to generate the summary report and here is the automated VBA.

Private Sub GenRpt_Click()
On Error GoTo Err_GenRpt_Click
Dim stDocName As String
Dim FrmId As String
stDocName = "Summary v2"
DoCmd.OpenReport stDocName, acPreview
Exit_GenRpt_Click:
Exit Sub
Err_GenRpt_Click:
MsgBox Err.Description
Resume Exit_GenRpt_Click
End Sub

I know that I am suppoed to insert soime kind of conditional staement into the code just after the DoCmd.OpenReport, but cant figure out how to pass the userid from the form to filter the report. My form has a text box “Text31” that contains a UserID, my report has a text box “tstUserID” that corresponds to the results. How do I limit the report results to only the userid displayed in “Text31” before my cmd button click?

  • 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-06-16T04:00:08+00:00Added an answer on June 16, 2026 at 4:00 am

    Something like*:

    DoCmd.OpenReport stDocName, acPreview,,"UserID=" & Me.Text31
    

    Where UserID is the name of a numeric field included in the record source of the report.

    If the field is a text data type, you will need quotes:

    DoCmd.OpenReport stDocName, acPreview,,"UserID='" & Me.Text31 & "'"
    

    It does not seem likely that the userID will include an internal quote mark, so the above should be safe enough, if it was likely, you would need to escape like so:

    DoCmd.OpenReport stDocName, acPreview,,"UserID='" _
        & Replace(Me.Text31,"'","''") & "'"
    

    You are adding a WHERE condition, and it takes a very similar form to the WHERE statement in a query.


    *The Syntax for Openreport is given as:

    DoCmd.OpenReport(ReportName, View, FilterName, _
        WhereCondition, WindowMode, OpenArgs)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a basic level of SQL understanding, hence needing help and thanks in
needing some help. I have two divs that I need to fill with images.
I am needing help with single sign on. I have siteA.com that requires login
I am needing some help with SQL syntax. Say I have a members table,
I am needing help with a credit card validation script. I have figured out
needing some help to just break down the problem. I have new users who
I have the below HTML and JQuery code and i am needing some help
I was hoping someone could help me, Im needing a way to have user
I am needing help masking a url. I have 2 domains but I do
I'm needing help with setting up the rewrite rules for my site. I have

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.