473,396 Members | 2,011 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.

Reading Data from Query and disply it in report

17
Hi All,
I am working on this project which requries making a product by adding one of 7 types of components (each type of component in turn has many variations).
product is made of about 25 components. the purpose of this project is to make a record of each item that has gone into making of each product.
I have created 7 tables for maintaining record of each type of component (which has 23 fields each) and there is a master table which will hold unique ID of each component for about 25 components. inshort each product has 7 x 25 x 23 = 4025+ details.
Now i have to generate a report which should give details of product made from its unique ID selected by user. the report should be for a single product made and not all the products made.
I am using access 2003 Pro with SP2 on Win XP

Now from report i want to run a query which will take input from the product number selected. result of the query should be assigned to text / lable placed in report. i am not able to figure out how to go about reading record data from a query into report.
can you guys help?
thanks !
Mar 14 '07 #1
23 1944
Rabbit
12,516 Expert Mod 8TB
I assumed everything is linked through some sort of product ID, you should be able to create a query that selects these product IDs.
Mar 17 '07 #2
cyclops
17
I assumed everything is linked through some sort of product ID, you should be able to create a query that selects these product IDs.
Hi Rabbit,
I wrote a query which displays correct data but can not read its results into the report. my problem is further compounded as i'll need to read data from atleast 25 queries into this report.

i have decided is to use Dlookup function to carryout this task.
is there a way to loop through the fields of a table without specifying the actual name of the field? say if a table has fields such as

name
lastname
middlename
age
address etc

can i address lastname by '2' or something like it?

thanks for your help.
Regards,
cyclops
Mar 20 '07 #3
NeoPa
32,556 Expert Mod 16PB
That's not how it works Cyclops.
You need to create a query (single query) that your report can run from. Sub-reports can also be used but each individual report needs a single datasource (usually a query) that it is bound to.
DLookup() is not a good idea for building up reports with. That's what queries are for.
Mar 20 '07 #4
cyclops
17
But NeoPa, my report will need to access multiple queries to get completed. if a report needs a single datasource then my report is not going to be complete.
any alternate method that i should try out?
thanks !
Mar 21 '07 #5
Rabbit
12,516 Expert Mod 8TB
But NeoPa, my report will need to access multiple queries to get completed. if a report needs a single datasource then my report is not going to be complete.
any alternate method that i should try out?
thanks !
Subreports.
Mar 21 '07 #6
NeoPa
32,556 Expert Mod 16PB
Subreports.
... and if that doesn't do the trick then consider multiple separate reports.
But don't forget, if you use a query you can get data from several different sources (tables). Hence 1 report may well work still.
Mar 21 '07 #7
cyclops
17
... and if that doesn't do the trick then consider multiple separate reports.
But don't forget, if you use a query you can get data from several different sources (tables). Hence 1 report may well work still.
Dear NeoPa & Rabbit,
subforms have solved my problem, thanks a lot for your suggestion !
I have made a form which asks the user to select a product number (from a combo box). this number is stored in a table for the queries on subform (about 25 of them) to access and display the results.
is there an efficient way to pass on the value from combo box to these queries?
thanks & have a nice day !
Cyclops
Mar 26 '07 #8
cyclops
17
when the VB code writes product number into the table that i have made, it gives an alert message saying "you are about to update 1 row(s)". is there a way to stop it?
thanks,
cyclops
Mar 26 '07 #9
Rabbit
12,516 Expert Mod 8TB
Dear NeoPa & Rabbit,
subforms have solved my problem, thanks a lot for your suggestion !
I have made a form which asks the user to select a product number (from a combo box). this number is stored in a table for the queries on subform (about 25 of them) to access and display the results.
is there an efficient way to pass on the value from combo box to these queries?
thanks & have a nice day !
Cyclops
You can pass a value from an open form to the query by referring to it with the syntax Forms![Form Name]![Control Name]
Mar 26 '07 #10
Rabbit
12,516 Expert Mod 8TB
when the VB code writes product number into the table that i have made, it gives an alert message saying "you are about to update 1 row(s)". is there a way to stop it?
thanks,
cyclops
Surround the part of the code that runs the SQL with:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.SetWarnings False
  2. ...
  3. DoCmd.SetWarnings True
Mar 26 '07 #11
cyclops
17
You can pass a value from an open form to the query by referring to it with the syntax Forms![Form Name]![Control Name]
thanks Rabbit for the tip ! i was able to get the required results.
Mar 26 '07 #12
cyclops
17
Surround the part of the code that runs the SQL with:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.SetWarnings False
  2. ...
  3. DoCmd.SetWarnings True
once i get the query input direct from the form, this is not requried now. thanks!
Mar 26 '07 #13
cyclops
17
now i am facing another problem. query that i have written now throws two records whenever the part1 qty is more than 1 where there is actually only one record. the query is as follows.

Expand|Select|Wrap|Line Numbers
  1. SELECT  DISTINCT Component1.*, productdetails.part1Qty
  2. FROM Component1, productdetails
  3. WHERE (Component1.Component1ID)=(SELECT productdetails.[part1] FROM productdetails WHERE (productdetails.[ProductNumber] =Forms!ProductNumber!ProductNo_ComboBox));
  4.  
what could i be doing wrong?
Mar 26 '07 #14
cyclops
17
now i am facing another problem. query that i have written now throws two records whenever the part1 qty is more than 1 where there is actually only one record. the query is as follows.

Expand|Select|Wrap|Line Numbers
  1. SELECT  DISTINCT Component1.*, productdetails.part1Qty
  2. FROM Component1, productdetails
  3. WHERE (Component1.Component1ID)=(SELECT productdetails.[part1] FROM productdetails WHERE (productdetails.[ProductNumber] =Forms!ProductNumber!ProductNo_ComboBox));
  4.  
what could i be doing wrong?
I think i got it. i should have created an inner join like this.


Expand|Select|Wrap|Line Numbers
  1. SELECT  DISTINCT Component1.*, productdetails.part1Qty
  2. FROM productdetails INNER JOIN Component1 ON productdetails.part1 = Component1.Component1ID
  3. WHERE (Component1.Component1ID)=(SELECT productdetails.[part1] FROM productdetails WHERE (productdetails.[ProductNumber] =Forms!ProductNumber!ProductNo_ComboBox));
  4.  
am i correct ?
Mar 26 '07 #15
cyclops
17
No, this does not seem to work. can u help?
thanks
Mar 26 '07 #16
NeoPa
32,556 Expert Mod 16PB
You are on the right lines, but to know precisely what you need, one would have to know how your data (tables) fit together.
Try posting the MetaData for both tables.
Here is an example of how to post table MetaData :
Table Name=tblStudent
Expand|Select|Wrap|Line Numbers
  1. Field; Type; IndexInfo
  2. StudentID; Autonumber; PK
  3. Family; String; FK
  4. Name; String
  5. University; String; FK
  6. Mark; Numeric
  7. LastAttendance; Date/Time
Mar 26 '07 #17
Rabbit
12,516 Expert Mod 8TB
Try:
Expand|Select|Wrap|Line Numbers
  1. SELECT  DISTINCT Component1.*, productdetails.part1Qty
  2. FROM productdetails INNER JOIN Component1 ON productdetails.part1 = Component1.Component1ID
  3. WHERE (productdetails.[ProductNumber] =Forms!ProductNumber!ProductNo_ComboBox);
  4.  
Mar 26 '07 #18
cyclops
17
You are on the right lines, but to know precisely what you need, one would have to know how your data (tables) fit together.
Try posting the MetaData for both tables.
Here is an example of how to post table MetaData :
Table Name=tblStudent
Expand|Select|Wrap|Line Numbers
  1. Field; Type; IndexInfo
  2. StudentID; Autonumber; PK
  3. Family; String; FK
  4. Name; String
  5. University; String; FK
  6. Mark; Numeric
  7. LastAttendance; Date/Time

here is the MetaData (partial)
table name =component1
Expand|Select|Wrap|Line Numbers
  1. component1ID; Autonumber
  2. Length; Integer
  3. Width; Integer
  4. Thickness; Integer
  5. Strength; Numeric
table name = productdetails
Expand|Select|Wrap|Line Numbers
  1. productID;autonumber
  2. productnumber;string;indexkey
  3. part1;Numeric
  4. part2;Numeric
etc.

i think i have got the solution...
Mar 28 '07 #19
cyclops
17
i have modified the query like this..

Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT Component1.*, productdetails.part1Qty
  2. FROM Component1, productdetails 
  3. WHERE (((Component1.Component1ID)=(SELECT productdetails.[part1] FROM productdetails 
  4. WHERE (productetails.[ProductNumber] = Forms!ProductNumber!ProductNo_ComboBox))) 
  5. AND ((productdetails.ProductNumber)=[Forms]![ProductNumber]![ProductNo_ComboBox]));
this has worked !

now i have next problem.... i hope i am not bothering you all too much ;-)
Mar 28 '07 #20
cyclops
17
I have now a report with about 25 subreports into it. If query from one of the subreports gives no result (ie. that part is not used for the product) then on main report it leaves a blank.
I do not want this bank to appear. The subreports below it should move up such that the report does not indicate in any way that there could have been a part here which is not used.
Any thoughts? Will share with you the solution as soon as I find one !
thanks & have a nice day !
Mar 28 '07 #21
cyclops
17
I have now a report with about 25 subreports into it. If query from one of the subreports gives no result (ie. that part is not used for the product) then on main report it leaves a blank.
I do not want this bank to appear. The subreports below it should move up such that the report does not indicate in any way that there could have been a part here which is not used.
Any thoughts? Will share with you the solution as soon as I find one !
thanks & have a nice day !
ha ha ha ! sometimes the solution is simple but one makes it complicated (atleast i did it!).
i just had to make the CanShrink Property of all subreports to Yes from default No and it did the trick !
Thanks a lot for your time! will get back to you incase i get stuck somewhere else.
Regards,
Cyclops
Mar 28 '07 #22
NeoPa
32,556 Expert Mod 16PB
Well, this is a turn-up for the books. Not only do we have an OP with multiple questions in this thread, but we also has one that's providing all the answers too. Obviously no impairment of his sight - Eh Cyclops?
With your responsive replies I would have been happy to offer further help but it seems it is no longer necessary (In such a short time too :D)
Mar 28 '07 #23
cyclops
17
Well, this is a turn-up for the books. Not only do we have an OP with multiple questions in this thread, but we also has one that's providing all the answers too. Obviously no impairment of his sight - Eh Cyclops?
With your responsive replies I would have been happy to offer further help but it seems it is no longer necessary (In such a short time too :D)

Hey NeoPa, thanks for your offer... I will save it for future ;-)
Mar 29 '07 #24

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

Similar topics

2
by: Dariusz | last post by:
Below is part of a code I have for a database. While the database table is created correctly (if it doesn't exist), and data is input correctly into the database when executed, I have a problem...
0
by: Andy | last post by:
Hi, In the code below (not pretty I know but it's an early version :-P) I'm having problems reading the data object back in. If I move the reading code to immediately after the section where it...
1
by: Magnus | last post by:
allrite folks, got some questions here... 1) LAY-OUT OF REPORTS How is it possible to fundamentaly change the lay-out/form of a report in access? I dont really know it that "difficult", but...
6
by: Robin Cushman | last post by:
Hi all, I need some help -- I'm working with an A2K database, using DAO, and am trying to read records into a Crystal Report and then export it to a folder on our network as an Excel...
2
by: amith.srinivas | last post by:
Hi all, From a word macro in VBA, I am trying to create a report in access DB. The report is based on a query with a parameter. I am using Set rpt = Application.CreateReport rpt.RecordSource =...
2
by: sara | last post by:
I am helping a non-profit track their elder clients and care given to the clients. The organization would like a report that shows various info on ALL clients, such as: # in each town, # and...
1
by: =?Utf-8?B?U2hlZXMgQWJpZGk=?= | last post by:
I read an article on the link: http://support.microsoft.com/default.aspx?scid=kb;en-us;306572 related to reading data from Excel using OLEDB The topic's heading is: How to query and display excel...
4
mb60
by: mb60 | last post by:
I generated a query based report from access table.I would like to save it in the table for future reference. Reason: Generated report is a mcq question paper of a chapter. If I would like to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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.