471,874 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,874 software developers and data experts.

OpenReport using a field name from a query

I have not much programming experience but would like to OpenReport in Access using a field name from a query.
I have a number of different reports.
I have a query that defines which report I want to open.
But the OpenReport command seems to only accept a report name not variable

Report Name Forms![Menu_Preview_Report_Project_Cost_Original]![Lst_Stage_Letter_File]



Could anyone please help
Oct 24 '16 #1
5 1078
1,430 Expert 1GB

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport Forms![Menu_Preview_Report_Project_Cost_Original]![Lst_Stage_Letter_File]
That assumes that Forms![Menu_Preview_Report_Project_Cost_Original]![Lst_Stage_Letter_File] evaluates to a string

Oct 24 '16 #2
Hi PhilOfWalton,
Thanks for your reply. For some reason the command does not take the string. Is there any other advice you could give me. Thanks Ralph
Oct 24 '16 #3
Hi PhilOfWalton
When I say string I mean path to a query that contains a field.
Oct 24 '16 #4
1,430 Expert 1GB
OK Lets do some diagnostics.

Presumably you have something like a List Box or Combo Box that shows the name of the report and assume the bound column is Column1 showing the report name.

Let's call it MyCombo

So try this air code
Expand|Select|Wrap|Line Numbers
  1. Sub MyCombo_AfterUpdate
  2.    Dim ReportName as String
  3.    ReportName = MyCombo
  4.    Debug.Print ReportName
  5.    DoCmd.OpenReport ReportName
  6. End Sub
Does the Debug give you the correct report name?

Oct 24 '16 #5
Thanks PhillOfWalton,
I really appreciate your assistance.
I will try this today and give you feedback later.
Oct 25 '16 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Consuelo Guenther | last post: by
2 posts views Thread by Ray | last post: by
2 posts views Thread by LoopyNZ | last post: by
2 posts views Thread by Michele Fondry via .NET 247 | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.