473,385 Members | 1,192 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,385 software developers and data experts.

Sending a Summed Query Field to a Field in Specific Table

Hello everyone,

This is simple enough, I am just not too familiar with SQL language.

Scenario:

I have a tblEquipmentHourLog where the daily hours from every piece of equipment are logged from a frmDailyTimesheet.

In tblEquipment, all the equipment info is stored which inlcudes a field called TotalHoursLogged.

I created a qryTotalHoursLogged based from the tblEquipmentHourLog where it groups and sums all the hours logged from every equimpent respectively.

Now, I just want to send back the summed hours into the TotalHoursLogged to all of the respective pieces of equipment in the tblEquipment.
Jun 10 '14 #1
5 843
twinnyfo
3,653 Expert Mod 2GB
Beaudry93,

Here is an easy option:

You could create an Update Query in which tblEquipment and tblEquipmentHourLog have an Inner Join on the Equipment ID. Then update the tblEquipment.TotalHoursLogged to:

Expand|Select|Wrap|Line Numbers
  1. tblEquipment.TotalHoursLogged + tblEquipmentHourLog.HoursLogged
This should do the trick. Let us know if you need any help with it.

BTW, welcome to Bytes!

Hope this hepps!
Jun 10 '14 #2
Hello Twinnyfo,

Thanks for the quick reply.

1) I see where your going with this by just adding it as you go but the only issue i have with an update query is it will always prompt an 'are you sure' every time you have to input an hour. (And with 30 some piece of equipment to input daily, the flow would be better if it could just send it automatically)

2) The description from your last comment is a little to vague for me;

i) 'Inner Join' - are you talking about a simple one-to-many relantioship?

ii) that line of text is suppost to go where? in the table, in the query...

Thanks,
Jun 10 '14 #3
I figured out a solution with your idea, i just wrote the following VBA Code in the HoursLogged_AfterUpdate:

TotalHoursLogged = DLookup("TotalHoursLogged", "tblEquipmentRental", "EquipmentNumber='" & Me![EquipmentNumber] & "'") + Me!HoursLogged
Jun 10 '14 #4
twinnyfo
3,653 Expert Mod 2GB
Beaudry,

In response to 1): your code to run the Update Query:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.Set Warnings False
  2. DoCmd.OpenQuery "qupdEquipmentTotalHours
  3. DoCmd.SetWarnings True
This will take away the verifications.

Concerning 2): Please see the attachment as an example. In this case, I am changing the value of the Field tblACCOfficers.FullName to the value found in atblPromotions.FullName. I am doing this on all records in which the NameChange flag is True. At the same time, I am updating that NameChange flag to False (since this record is being updated to the new name. Notice how the two Tables are have an Inner Join on the SSN. This ensures that the officer with the SSN of "123-45-6789" in tblACCOfficers is matched with the same officer in atblPromotions. But, this update query will only update the officer's FullName if the NameChange flag is true.

NOW, I hope this makes sense.

Please don't hesitate to ask questions! I knew nothing at one point, but it was by asking questions and pushing myself that I learned how to make very robust Databases.

Let me know how this works.
Attached Images
File Type: jpg Update Query.jpg (53.5 KB, 116 views)
Jun 10 '14 #5
twinnyfo
3,653 Expert Mod 2GB
Your workaround will also suffice. As you can see, there are always more ways to skin a cat. It just dependds on when and where you want your updates to occur.

Cheers!
Jun 10 '14 #6

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

Similar topics

2
by: Felix | last post by:
Hi, I've a problem: I want to have the result of my Mysql Query in a Table in my php file. Now I've this: <?
3
by: Ken Wilkins | last post by:
Is there a way to add a field to a table when the same one is created in another table? I'm working with keeping track of software for different versions of OS. If I add a field to the Win98...
13
by: Peter | last post by:
Can anyone tell me how to change the data type of a field in a table created with a make table query? The field is a binary and must be changed to text. alternately does anyone know how to specify...
13
by: MLH | last post by:
I have a form with two controls: !! - combo box !! - text box A button on the form tries to run this SQL when clicked... INSERT INTO BodyMsgsSent (ToWhom, BodyText) SELECT DISTINCTROW !! AS...
3
by: John young | last post by:
I have been looking for an answer to a problem and have found this group and hope you can assist . I have been re doing a data base I have made for a car club I am with and have been trying to...
2
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...
1
by: deko | last post by:
If I allow users to create a QueryDef by entering an sql statement in a text box, can I restrict that query to a specific table? Is there some way to throw an error based on what table a query...
1
by: WillieW | last post by:
Hi folks, I have Access 97 and have set up four tables, each with a Primary Key with a file name manually entered. For example, the four tables relate to information stored in a paper file, on...
1
by: sshafer1 | last post by:
I have a form that is using query as the backend 'table'. I did this so that I could display query fields in my form that have been calculated. 1. How do I write those query field values to a...
2
by: shalskedar | last post by:
In the Database I need to delete a record from a specific table.. For ex-There is a field called as "Type" contained in the Master table "Type" . I need to build the query criteria in such a way...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...

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.