468,770 Members | 2,106 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,770 developers. It's quick & easy.

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

eg:
OpenReport
Report Name Forms![Menu_Preview_Report_Project_Cost_Original]![Lst_Stage_Letter_File]

or

DoCmd.OpenReport:=Forms![Menu_Preview_Report_Project_Cost_Original]![Lst_Stage_Letter_File]

Could anyone please help
Oct 24 '16 #1
5 905
PhilOfWalton
1,430 Expert 1GB
Try

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

Phil
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
PhilOfWalton
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
  7.  
Does the Debug give you the correct report name?

Phil
Oct 24 '16 #5
Thanks PhillOfWalton,
I really appreciate your assistance.
I will try this today and give you feedback later.
Regards
Ralph
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.