473,396 Members | 2,109 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,396 software developers and data experts.

Run a report using data in an open form

I have a report that runs based on parameters set in the underlying query. For example, in the "account number" field in the query I've entered [enter account number] in the criteria area. This allows the user to select a certain record. The record opens with all relevant data on a form. From the form, the user can then run specific reports about that record that also use the same [enter account number] criteria. I know there is a way to have access copy the account number from the open form and use it to run the report but I can't figure out the macro. Please help...
Aug 18 '09 #1
5 6491
ajalwaysus
266 Expert 100+
You make this code the record source of the report and then execute the report from the form.

Expand|Select|Wrap|Line Numbers
  1. SELECT * 
  2. FROM Table1
  3. WHERE Table1.Field1 = Forms![FormName]!FieldName
-AJ
Aug 18 '09 #2
Interesting. That works but then I lose all the other data fields that are shared between the table record and the report. Do I have to write the same code for every shared control on the report?
Aug 19 '09 #3
ajalwaysus
266 Expert 100+
If I understand you, then you need to write code like this:

Expand|Select|Wrap|Line Numbers
  1. SELECT * 
  2. FROM Table1
  3. WHERE Table1.Field1 = Forms![FormName]!FieldName1
  4. AND Table1.Field2 = Forms![FormName]!FieldName2
  5. AND Table1.Field3 = Forms![FormName]!FieldName3
  6.  
Let me know if this is what you were after, otherwise please post a more specific explanation of what you need to do.

-AJ
Aug 19 '09 #4
I’m using reports to build documents. My goal is to allow the user to only enter the record specific information once and then print all documents (separate reports) necessary. The user will enter a form and input the common field one time. That form will have all available documents on it as buttons. When the user presses a button, I need Access to use the data on the open form as criteria to open the report and display all data fields available in the record.

When I use the code you suggested, only the one field is selected, not the entire record.

For example. In the table let's say there are 24 fields. On the form, the user will enter data for one field "account number." Based on the report selected, Acess should use the account number field to go to the table and pull 12 fields of the 24 into the report.

I could make the report's record source a query where the criteria is [enter account number] but then the user has to enter the account number for every report they run...tedious.

I tried both ways you suggested but can't get it to pull in the entire record.

Clearly I’m not a professional…just a recreational user. Not sure if I’m explaining my problem correctly.
Aug 21 '09 #5
ajalwaysus
266 Expert 100+
I don't think I still understand what the problem is. If you pass the ID of a desired record to your report, your report should be able to then run off that single ID and pull back all information in the table if you are using an SQL statement as you record source. If you have multiple reports that use that ID then it should be no different.

If possible, could you remove all sensitive data from your tables then upload the mdb in a zip file to this forum, perhaps going straight to the source would help me understand your issue.

-AJ
Aug 21 '09 #6

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

Similar topics

4
by: deko | last post by:
I can't move a multi-page report to the last record unless I keep the popup form (that defined it's subreports) open. DoCmd.OpenReport "rptStandard", acViewNormal DoCmd.Close acForm,...
1
by: N. Graves | last post by:
Hi, I want to have a Search Dialog box that has several text box and fields to build a search and display the results in a form. I can do everything that I need to if I us a report but I would...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
2
by: CSDunn | last post by:
Hello, I have an Access 2003 report that opens in print preview and then maximizes upon clicking a button from a form. The OnClick event of the button fires a macro to open the report. How can...
6
by: Bob Alston | last post by:
I am looking for Access reporting add-in that would be easy to use by end users. My key focus is on selection criteria. I am very happy with the Access report writer capabilities. As far as...
1
by: lorirobn | last post by:
Hi, I have a report that works just fine. Now I would like to add the capability to choose selection criteria to limit what is displayed. I created several reports that do this, but they used...
6
by: fieldja | last post by:
I have a form called OwnerForm. It contains a combo box called Owner. The combo box looks up names from a table called OwnerName. It contains fields called OwnerID and Owner. I also have a main...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
3
by: jambonjamasb | last post by:
Hi I have two tables: email_tbl Data_table Data table is is used to create a Form Data_form
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.