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

Query/Form pull from several tables, multiple common fields

I'm buildling a form for tracking printer costs. This form will display data from several different tables pulled together by queries.

formPrintCost will display:
  • printer information from tblAssets
  • support, maintenance, downtime and supply information and costs from tblSupport
  • page counts from tblPrinterMeter

The main control in formPrintCost is listPrinter, which is a List Box with all the printers in tblAssets. Selecting a printer will display all the information described above as well as totals for the costs, cost per page, supply costs, service costs, total downtime, and (eventually, as I learn enough) a report button to generate graphs showing the cost history.

So far I've built queries that display the appropriate information based on the selection in listPrinter, but to make the VBA underlying formPrintCost easier (I'm feeling more confident working with SQL than VBA based on my current skill levels), I'm trying to build one master qryPrintCostMaster that will pull nearly all the data necessary for formPrintCost.

The current query structure is as follows:
On making a selection in formPrintCost!listPrinter, qry PrintCostAssets pulls the selected asset information:
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM tblAssets
  3. WHERE (((tblAssets.ID)=Forms!formPrintCost!listPrinter));
One of the fields returned is tblAssets.AcquireID. qryPrintCostAcquire uses this field to return the related fields from tblAcquire:
Expand|Select|Wrap|Line Numbers
  1. SELECT tblAcquire.*
  2. FROM tblAcquire INNER JOIN qryPrintCostAssets ON tblAcquire.ID=qryPrintCostAssets.AcquireID;
In formPrintCost, using a tab control, I'll show a historical list of support tickets for the selected printer and a list of page count meter readings from tblSupport and tblPrinterMeter, respectively. This is well within my current ability and will be a simple List Box control with sources in qryPrintCostSupport and qryPrintCostMeter and a simple requery command in the VBA upon selection of a printer in listPrinter.

Also based on qryPrintCostSupport, I'll be totalling the value of the Cost field in field SCost in query qryPrintCostSupportCostTotals.

And based on qryPrintCostMeter, I want to pull the latest entries for Color, Black, and Total page counts from the fields CMeter, BMeter, and TMeter into fields CCount, BCount, and TCount in query qryPrintCostMeterTotals.

qryPrintCostMaster will need to pull all the fields from qryPrintCostAssets, qryPrintCostAcquire, qryPrintCostSupportCostTotals, and qryPrintCostMeterTotals.

Since each of these queries will have only one row of data when an entry is selected in formPrintCost!listPrinters, this should be relatively simple, right?
Expand|Select|Wrap|Line Numbers
  1. SELECT qryPrintCostAssets.ID AS AssetID, qryPrintCostAssets.UID, qryPrintCostAssets.ModelID, qryPrintCostAssets.Status, qryPrintCostAssets.Dept, qryPrintCostAssets.SubDept, qryPrintCostAssets.SN, qryPrintCostAssets.Box, qryPrintCostAssets.BoxDrop, qryPrintCostAssets.NetName, qryPrintCostAssets.MACAddress, qryPrintCostAssets.IPAddress, qryPrintCostAssets.BESSNo, qryPrintCostAssets.IMMS, qryPrintCostAssets.Description, qryPrintCostAcquire.ID AS AcquireID, qryPrintCostAcquire.Method, qryPrintCostAcquire.Price, qryPrintCostAcquire.DateAcquired, qryPrintCostAcquire.Number, qryPrintCostAcquire.LeaseBegin, qryPrintCostAcquire.LeaseEnd, qryPrintCostAcquire.Vendor, qryPrintCostMeterTotals.BCount, qryPrintCostMeterTotals.CCount, qryPrintCostMeterTotals.TCount, qryPrintCostSupportCostTotals.SCost
  2. FROM qryPrintCostAcquire, qryPrintCostAssets, qryPrintCostSupportCostTotals, qryPrintCostMeterTotals;
  3.  
Right. There are no errors, but all that displays in Datasheet View is all the appropriate field headings and no data.

Running each individual query shows me the correct data based on the selection in formPrinterCost!listPrinters, but qryPrintCostMaster is empty.

First question: Is this a reasonable way to accomplish what I'm trying to accomplish, or am I way off based and trying way too hard? I'm rather new to Access and VBA and this the first time I've tried merging several queries into one, and as mentioned before, I feel more confident writing SQL than working in VBA, being still primarily at the Copy/Paste level in VBA and just into the "I know three different things" level in SQL.

Second question: If I'm not totally off-base, where am I going wrong? Do I need an INNER JOIN or similar to make this query work as well? If so, how would I match the multiple and different related fields among the multiple queries?
Aug 4 '10 #1
0 1595

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

Similar topics

1
by: Dominic Marks | last post by:
Hi, (I apologise if this is the wrong list, I haven't posted to a postgresql.org mailing list before, general seemed like a good catch-all) I am trying to implement a centralised...
1
by: jbroome | last post by:
I have several tables that contain the same information as Identifying records but then with additional info that differs from table to table. e.g. 1 database of school students with their...
3
by: Joanna Epstein | last post by:
I have several tables formatted as follows: ITEM #, ITEM DESCRIPTION, PL, JANUARY ITEM #, ITEM DESCRIPTION, PL, FEBRUARY And so on… I need to create a final report that merges all of the...
7
by: RLN | last post by:
Re: Access 2000 I have three history tables. Each table contains 3 years worth of data. All three tables have a date field in them (and autonum field). Each table has the potential to contain...
3
by: Reader | last post by:
Hello all, I am joining two tables in a query and the output should be all those records where two fields in table1 match two corresponding fields in table2. I joined the tables using both...
18
by: TORQUE | last post by:
Hi, Im wondering if anyone can help me with a problem. I have a form with more than 50 unbound fields. Some of the fields will be blank from time to time. This seems to be where im having...
3
by: kcddoorman | last post by:
I'm making a shop order entry system. Basically I take a work order that a sales person writes and rewrite into a door builders language. I'm having trouble with the form's record source. I have...
1
by: kellyj | last post by:
Hi My problem is i have 5 tables with diffirent fields in each, I have IDNum as a common field in each and i want to creat a form to enter data to these tables. any help would be a great help ...
4
by: gillianbrooks91 | last post by:
Forgive me for asking this question, I've trawled through nearly every available post on this subject that I can find for a few weeks now but nothing quite points me in the right direction. I'm...
13
by: heart01 | last post by:
Hello All, I have been trying to work this out myself based on a response that I received yesterday which worked however I think I am lost in the process. I have a form which I have 6 calculated...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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.