473,237 Members | 1,234 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,237 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 1322
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

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

Similar topics

by: Consuelo Guenther | last post by:
Hello, I have an asp page that has a function that connects to an Access database. I am using Javascript. Is there any way to reference the field name in the database through a variable in a sql...
by: Louis | last post by:
Is there a switch or a setting in Access so that a group by query doesn't return a field name SumOf(original field name)? Especially when you chain multiple queries together you'd get...
by: Ray | last post by:
I tried to change the field name in a query using "New Name: ". It did not work at all and just display the caption of the Field Name. Is it possible to change the field name or use a new caption...
by: LoopyNZ | last post by:
Hi, (Access 97) I'm creating a query (QRY_SUMMARY) to join a query (QRY) to itself (QRY_1). I'm returning QRY.* and selected fields from QRY_1. With each field (field_name) I return from...
by: NickName | last post by:
The following example may further clarify the question, Select fieldA, filedB, fieldC >From tblX Where fieldD = Forms!formName!controlName What I'd like to know is how to determine or get...
by: Bob Alston | last post by:
I have a database with user definable fields. These are in the table as Field1, Field2, etc. I store the labels in another place and on the form, I display the labels they designate instead of...
by: Michele Fondry via .NET 247 | last post by:
hello. I have a webform form app in vb.Net that uses a SQL query. I am trying to use the substring function, but get the following error: Description: An unhandled exception occurred during the...
by: jaceyk | last post by:
Is it even remotely possible to update field names to the correct field name for the same table using a data definition query? We have a utility that spits out data in an Access database for use in...
by: Paul Howarth | last post by:
Question from a Novice: I have a Query which is based on a Crosstab Query. One of the fields in the Query is "Client". I can "hardcode" a Criteria for the "Client" field and the Query works...
by: jahansam | last post by:
Hi, in MS Access I want to create a SQL query where field name can be taken from a text box or combobox. For example, I have a table name "bank" and it has fields...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.