473,659 Members | 2,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loop VBA for Dmax records from subtable

74 New Member
Lets say i have 2 tables (ok i really do). One is tblShipping, the other is tblShippingDeta ils. I need to run a query to find all of the maximum values of a qty backordered, so that i can find out what is left to so that i can multiply it by its price and determine how much is still left to ship, but for all open orders. We do partial shipments, and i am not recording the ship values on another table, it is appending the original table, because so many of the values change.

So I decided that i would find the maximum backordered qty, subtract it from the original qty, then multiply what is left by the unitprice. I know how to write a temp table, use dmax("QTYBackOr der","tblShippi ngDetails","Job Number ='" & [this is the problem part]) to get the value from the details table, how do i then move to the next job number to look for the max "qtybackord er". I am not sure how to look for the next job number to write to a temp table so that i am just reading a table with all of the max quantities.

Should i first sort the table, if i do, how do i move to the next different JobNumber. I hope i have given enough information. If i knew how to find the max for each jobnumber with a query(wizard of course, sql scares me, lol) then i would just use the qry as the record source, but i couldnt figure it out. I couldnt figure out what criteria to use for job number..... or how to word it.

Any help is greatly appreciated. If i havent given enough information, feel free to tell me.
Apr 23 '09 #1
7 2719
NeoPa
32,568 Recognized Expert Moderator MVP
I suspect the info is all (mostly) there K, but the problem is that the order it's presented in is so random that it's very difficult to work with.

I don't understand why you're looking for a maximum value rather than a sum, if you're trying to determine what has been shipped.

Your line of code however, should be constructed differently depending on what type of field [JobNumber] is.
You don't say how you have access to the required JobNumber value, so I shall assume, for the sake of clarity, that you have a variable with it stored in. If it is a string value then this will be strJobNo :
Expand|Select|Wrap|Line Numbers
  1. ... = DMax("[QTYBackOrder]","[tblShippingDetails]","[JobNumber]='" & strJobNo & "'")
If it is numeric, then it will be lngJobNo :
Expand|Select|Wrap|Line Numbers
  1. ... = DMax("[QTYBackOrder]","[tblShippingDetails]","[JobNumber]=" & lngJobNo)
Apr 23 '09 #2
kstevens
74 New Member
Sorry,

I missed something very easy there, that you pointed out. I have (with a query)taken the first jobnumber record (there are multiples, due to the fact that we sometimes ship partial orders) and the sum of the qty shipped, i dont know why i was trying to do this the hard way.....Thanks NeoPa.

Btw - I could have inserted the criteria for jobnumber, but i needed to run the query on all records.
Apr 23 '09 #3
NeoPa
32,568 Recognized Expert Moderator MVP
I don't pretend to understand you clearly K, but if I've helped then I'm pleased.

I do get the impression that you're now processing with a query rather than a single (or even multiple) call(s) to a Domain Aggregate function (DMax). If so, that certainly seems a more sensible approach.

Success with your project.
Apr 23 '09 #4
kstevens
74 New Member
Just for a little clarification: I have reports for the president and multiple vice presidents that let them know what the $ value of what we have shipped for the month is. Then they wanted the value of what was still in house, for all open orders that have either not shipped or have not completely shipped. I know i was a little random, but i was having trouble, and beleive it or not just by you saying the word "SUM" helped me tremendously.

My original method was query, i was having trouble with it and decided i had more options if i used code, with dlookups and create table, and append queries, while looping.....(no t ever thinking about summing the actual shipped qty's..... brain fart). But i have the query finished and it all seems very simple now.

Sometimes i just need a person that understands access to bounce questions off of, and make me think for myself. Need a job? lol

Thanks again.
Apr 24 '09 #5
NeoPa
32,568 Recognized Expert Moderator MVP
@kstevens
I'm absolutely not kidding when I say that's exactly the same for me.

Sometimes, just talking to someone who has the intelligence to nod wisely as I stream my thought processes out, can help to clarify things enormously. If they actually know something (even just a little) about what I'm saying as well, that's a bonus.

PS. Thankfully, I'm not looking for alternative employment at this (very difficult) time.
Apr 24 '09 #6
OldBirdman
675 Contributor
I agree with you. If I think the person I am talking to MAY (even with low probability) be able to answer the question, I can answer half of them myself. But if I ask my Teddy Bear, it doesn't work.

I get half my questions answered by creating the questions for this forum. I never actually have to submit them, 'cause I know the answer.

Part of it is that if I am going to ask someone else, I have to actually formulate the question, and get rid of all those partial/fuzzy ideas running around in my head. I never post in haste.
Apr 24 '09 #7
NeoPa
32,568 Recognized Expert Moderator MVP
No you don't. I always know if a thread has your name on it then it will tax me. Always the question is fully explained too.
Apr 24 '09 #8

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

Similar topics

6
3815
by: asad | last post by:
Hi, i have some problem in showing data. I have two tables First table(containing Hosting categories) Second table(Containg catagories data lik url,keyword,description.....etc) I want to display catgories names from first table and then diffren catagories total records from second table, like this
1
3152
by: Scott Gerhardt | last post by:
Hello, I am new to the list, my apology if this question is beyond the scope or charter of this list. My questions is: What is the best method to perform an aggregate query to calculate sum() values for each distinct wid as in the example below, but except for all wid's (not just WHERE wid='01/1-6-1-30w1/0'). Also, performance wise, would it be better to build a function for this query. The table has 9 million records and these...
4
13774
by: dmisen | last post by:
I have data on air pollution coming from sources across the country, and control options for reducing pollution from each source. The example below shows data for: - 2 sources (plant_ID "001" and "008") - total tons of pollution emitted from each source (20 and 25 tons, respectively) - an ID code for the each control device that could be applied to reduce the emissions - the control efficiency for each control device (percent that it...
1
1911
by: David | last post by:
Hi, I'm having trouble copying table data to new records. I have two tables as follows: *** Specifications (Table) specification_ID (field) LINKED product_ID (field) specification_header (field)
4
4049
by: gps | last post by:
I'm trying to use Dmax to dip into a my invoice header table and pull the maxium invoice number out of it. I'm running Access 2007 on Vista Business, but had the same prob with Access 2003 on XPP. Here's a snapshot of the table data: InvoiceID 79571 79572 ACCT ACCT
4
4591
by: jacc14 | last post by:
Hi This is the second query I have had with Dmax. The first one I resolved as it was in a form and by using DMAX everytime I click for new record it gave a new order number ie dmax("ordernumber", "tbl_orders")+1. This problem is quite different and I am hoping someone out there can advice. I have a group of orders in a table. I tick a box to select which records I want to batch for that particular month. An update query then copies...
0
1934
by: Richnep | last post by:
Hi all,. I have a small issue I would like to resolve with VBA. I have a form which it's fields are bound to a table. Within that form is a subform which is a subtable. Tables relationship is a one to many from the main table to the sub table.
6
4040
by: kstevens | last post by:
I have tables setup with a main table for information and a subtable that records the "multiple" records for the main record. I have written a query to go in and find Null or "" values to delete records that somebody started and closed out of, but then I realized that it wont delete the main records that information is recorded in if the sub record only contains 1 New record, because they arent neccesarily Null or "". Does anybody have any...
21
4626
by: DanicaDear | last post by:
I have a report named "rptHOTSTICKS_EXPIRING" based on a query named "HOSTICKS_SHIPPING_REPORT Query". The query contains these fields: ORDER_NUM (text) CUST_NUM (text) Name, address, contact info, I think not important to this thread DATE_SHIP (date) Then I have a field STICKS_EXPIRE: DateAdd("yyyy",2,) with criteria Between And where and are parameters.
0
8330
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8626
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.