INSERT INTO With Summation And DSUM Difficulties

Aug 29, 2007

hello all,

i stumbled upon this site via google while i was trying to find a solution to my problems! i'm a pretty proficient pl/sql writer and this is my first time trying to learn jet sql so a lot of the things i'm used to in pl/sql can't be done in jet sql!

1) i'm trying to create a summary record from RR_FT_COMPONENT to RR_FT_TOT_PAYOUT. this is basically summing some payout fields by grouping by payee_id and period_id. from my research i've seen that jet sql doesn't like sum or group by's for updates. is it the same for doing select statements for insert into?

when i run the query i get the following error: "ms access can't append all the records in the append query. MS access set 0 fields to null due to a type conversion failure"

all of the fields on both tables have the same type. is this a group by and sum problem? i ran the select statement separately and it worked fine.

code:
INSERT INTO RR_FT_TOT_PAYOUT ( market, region, financial_center, payee_id, employee_name, manager_flg, lic_code, job_code, period_id, volume, cp_spread, ytd_spread, cp_comm, ytd_comm, prior_yr_flag )

SELECT max(rc.market), max(rc.region), max(rc.financial_center), rc.payee_id, max(rc.employee_name), max(rc.manager_flg), max(rc.lic_code), max(rc.job_code), rc.period_id, sum(rc.volume), sum(rc.cp_spread), sum(rc.ytd_spread), sum(cp_comm), sum(ytd_comm), max(prior_yr_flag)
FROM RR_FT_COMPONENT AS RC
GROUP BY rc.payee_id, rc.period_id;


2) in this next code i'm trying to sum spread information in the ft_txn_summary table for a given payee_id, market and period_id. i'm using dsum and have the appropriate joins to keys on the tables, yet this update sums ALL records in the ft_txn_summary table rather than summing the specific payees in the join. any idea on what's wrong or how to debug dsums?

code:
UPDATE rr_ft_component AS rc SET rc.cp_spread = Dsum("txn_spread","ft_txn_summary","ft_txn_summary.payee_id= " & [rc.payee_id] AND "ft_txn_summary.market= " & [rc.market] AND "ft_txn_summary.period_id= " & [rc.period_id])
WHERE rc.component_name='Total Revenue';


any help would be appreciated! thank you!

View Replies


ADVERTISEMENT

Query On Summation

Jun 7, 2007

Hello Mdb Gurus,

I have a huge database but this is only a sample. Basically, I want to combine the monthly_qty, annual_qty_used and months_of_use for the similar Part-Numbers (ie. with or without the 'W' suffix). Example, part numbers 0010-20524 and 0010-20524W should be treated as alike.

The Table 'wrong_outcome' generated from the saved query would not be able to handle this kind of situation. The correct Table should be exactly like the one I created: 'should-be_outcome' but I have no least idea how to query this. Can someone help me with a query or SQL.

Any help is very much appreciated. Many thanks.

View 8 Replies View Related

IIf-summation Problem

Mar 20, 2007

Hi,

I've found this board very helpful in the past and was hoping someone would be kind enough to help me out again. I have a problem similar to the one below:

I have a table which tells the supplier we ordered from and number of each of the 5 types of fruits my store orders from the particular supplier(apples,oranges,pears,etc). Those are my 5 columns.

I need to create a sixth column which I will call 'Multiple Types' in order to tell if we ordered more than one type of fruit from that particular supplier(and how many total fruits). Therefore, the following condition has to be met: If two or more of the five columns is greater than 0, I need this sixth column to sum the values of all the 5 columns(thereby giving me the sum of all the fruits ordered from that supplier). If this condition is not met, I need the column to be equal to zero.

Do you have any ideas how I might accomplish this task?

Thank you all for your time.

View 1 Replies View Related

Emailing Difficulties

Feb 22, 2006

I've been working on a database for the last month or so. It's been a slow process since I've been learning Access and VBA in the process.

But my supervisor wanted a copy of it as a progress check to send to his boss. So I sent an email with a copy of the database as an attachment.

THe email went through, but when my supervisor tried to open said email, a dialogue came up saying that Access couldn't open the file because it was "out of the intranet or on an insecure site" or something along those lines

I was just wondering what this meant and how I would be able to send my boss a copy of the database so that it can be reviewed and such. Would this require splitting it?

Thanks in advance,
Nathan

View 2 Replies View Related

Lookup Difficulties

Aug 29, 2007

I'm having trouble creating my query
I have a table representing the company's products. Ever once in a while the products get replaced by a newer product. Like below
_____________________________
Product - Replaces - Replaced By
a..................................b
--------|----------|-----------
b.................a...............e
--------|----------|------------
c
--------|----------|------------
d
------------------------------
e.................b

Can someone help me write a query so the result below will be shown in
three fields.

Product - Replaced by level 1 - Replaced by Level 2-Replaced by level 3
....a..................b.......................... . e......................and so on

View 4 Replies View Related

Difficulties With System

Feb 8, 2006

Hi, I’ve been having some problems being able to do some things on my database, I was doing ok creating my system but now I’m a bit confused about what to do and I’ve been trying but getting no where. Firstly on my order form I need a total for the products which are in an subform and after the order is complete I need to be able to create an invoice and keep all the order information in the 'invoice' and 'invoice details' tables. I also need it to update the stock levels after the order is complete. Then I had created a tab in 'view customers' and I wanted to have it so that past customer orders could be viewed. Any help is appreciated; here is a link to my system:
'Gamez System' (http://www.savefile.com/files/5877934)

Thanks, Bob.

View 1 Replies View Related

Difficulties On My Form. Help Please!!!!

Dec 14, 2006

Hi! I have a problem with my form [EDITAR], the problem is that i did a form basing me on a table, but now i want to create a command that when i press it, it has to let me edit my data. i don't know how to explain me very well. i want to change my data but changing it with my form and save that information.

the other problem is that i want to create the same form for but only to add new data on the same table, i want to create a command that i will press if i want to add new records.... help i really need help:confused:

View 7 Replies View Related

Update Difficulties!!!!!

Jun 29, 2006

Hey guys,
This has really got in my nerves.....

I have a table with 2 fields (pr_row, pr_col).
All i want to do is:
I want to update the table so that every 21 records, the pr_col field will increase from 1 to 21 and so on, and the pr_row field
will remain with the same value (but increasing by 1 every 21 records)
Explaining
pr_row-pr_col
===========
1 - 1
1 - 2
1 - 3
.
.
.
.
1 - 21
2 - 1
2 - 2
2 - 3
.
.
.
What is the update query that i must execute?

View 1 Replies View Related

How Can I Do Summation To Time Type Field??

Jan 17, 2007

hi,

I have atable with fields time in and time out (short time type), in aquery i did a diffrence between that to fields, so I can know to evry employee every day how many hours work.

but, my problem is how do summation to the work hours to the month (it's a short time type).

example, an employee work from 8:30 to 15:00 in the first day, second day work from 9:10 to 14:20 ....etc
at the end of the month i want to have report from query which give me sum. of hours the employee workes.

thanks to help me

suhad

View 2 Replies View Related

How To Bind A Textbox To Summation Query Value

Dec 23, 2013

How can I bind a textbox to summation query's value? I tried the formula builder and this did not work:

=[qryAutoMatchSum]![SumField]

View 1 Replies View Related

Difficulties With Getting The Right Responce From My Queries

Oct 27, 2005

Hello,

I am having difficulties with working out how to create a correct query from my database. :confused:

These are the two results I require:

What strength of whisky sells the best at Christmas (How do I do an 'In-Between' date condition regardless of the year? i.e. >= #01/12/____# AND <= #31/12____#)
Which companies have not purchased at least one bottle from each region?

However, I am not sure how I would go about getting these specific results from the database. I have done serveral previous questions based on the database (which can be seen in the .mdb file) however these two are proving troublesome. I have attached the database to this post if anyone who is at ease with queries would be kind enough to have a quick peeky at it.

Any help would be greatly appreciated !

Note. the database information is fictisious. :rolleyes:

View 1 Replies View Related

Access Importing Difficulties

Oct 26, 2005

Hey,
I have an access database that imports a certain range of a certain sheet from 30 files all of which are in the same folder and I am trying to get that BOTTOM MOST peice of code to automate the process.

Now one of my many complications was that the excel files are workbook protected, and so it would give the 'cannot decrypt error' that’s why I have all that code regarding unprotecting it... but for some reason its not working

It gets to the line where it gives it the password and it tells me the password is unaccepted, and yes the password is correct...

It must have something to do with the do loop, because it works fine whenever I used it over one import file and thus without the loop... Like this for ex works perfectly fine

Code:Public Function TransferSP()ExcelFile = "G:CBTFILENAME"On Error GoTo ErrTrpStartAgain: DoCmd.TransferSpreadsheet acImport, 8, "TEST", "G:CBTFILENAME", True, "Access_Upload!C13:L34"xlapp.ActiveWorkbook.Protect (blah)ErrTrp:If Err.Number = 3161 Then 'Encripterror so unprot wb xlapp.Visible = False 'Open Excel xlapp.EnableEvents = False 'Disable Events xlapp.workbooks.Open ExcelFile 'Open File xlapp.ActiveWorkbook.Unprotect (blah) 'Unprotect xlapp.ActiveWorkbook.Save 'Save xlapp.EnableEvents = True 'Enable Events xlapp.ActiveWorkbook.Close 'Close File xlapp.Quit 'Quit Excel GoTo StartAgain 'Try and Import againElseEnd IfEnd Function

So Please tell me what is wrong with this bottom piece of code...

And secondly, I have a table which contains a list of names, whether they are active (checkbox) and their filenames each on a column of its own...

Can anyone show me how i can include into my code (assuming the password problem is fixed) that would allow me to place an if statement that checks whether the user is active or not... IF he is then it imports his file (using the filename column next to his name).... If he is not active then it just goes onto the next person without importing him/her

Right now I have it importing all the files in that folder

Code:Option Compare DatabasePublic xlapp As New Excel.ApplicationPublic Sub ImportAll() Dim strPath As String Dim strFileName As String strPath = "G:CBT" 'Set Path strFileName = Dir(strPath & "*.xls") 'Set first file Do On Error GoTo ErrTrp DoCmd.TransferSpreadsheet acImport, 8, "Test 2", strPath & strFileName, True, "Access_Upload!C13:L34" ErrTrp: If Err.Number = 3161 Then 'Encription error so unprotect workbook xlapp.Visible = False 'Open Excel xlapp.EnableEvents = False 'Disable Events (Macro's) xlapp.workbooks.Open strPath & strFileName 'Open File xlapp.ActiveWorkbook.Unprotect (blah) 'Unprotect 'Try and Import again DoCmd.TransferSpreadsheet acImport, 8, "Test 2", strPath & strFileName, True, "Access_Upload!C13:L34" xlapp.ActiveWorkbook.Save 'Save xlapp.EnableEvents = True 'Enable Events xlapp.ActiveWorkbook.Close 'Close File xlapp.Quit 'Quit Excel Else End If strFileName = Dir() 'look for next file If strFileName = "" Then 'no more files Exit Do End If LoopEnd Sub

Please let me know what I can do with this
I am a novice at coding...Just tell me where to put the code

Thanks

Ayyad

View 11 Replies View Related

How To Select Records Based On Summation Of Another Field

Jan 14, 2007

Hello,

I have a dataset that consists of Stands within a forest inventory. There are two Fields: the first field is StandValue (dollars), the other field is the StandArea( hectares).

I want to select the highest valued stands BUT the sum of the individual areas found in "standArea" cant exceed 10,000 hectares. Can anyone help me figure out an SQL query for this, or any other suggestions on how to proceed would be greatly appreciated, thanks
Greg

View 2 Replies View Related

Forms :: Summation Queries - Too Many Fields Defined

May 24, 2013

Quick summary (See Attached)

Data is stored in 11 tables each with matching primary key. Each table has in the range of 20 fields of which only numbered data type are being used in calculations.

Each Data table has 3 augmenting queries. All these queries work individually.

Summarizing query "QStationCountList_Sum" works fine.

Calculating a summation score by each "Master_PS_ID" works fine if I only try to summarize data by 3 of the calculating queries. As you can see in the attached database "QStationTotalScore1_6" query based on 6 gives "Too many fields defined". (I have tried so many fixes I can not remember and received messages such as "To Complex") While a similar query on 3 works fine.

At this juncture I plan to build 4 new partial sum queries each from 3 collecting queries and then build a 5 Summation query adding the results from the Sum queries. Surely there is a better way.

View 3 Replies View Related

Difficulties In Designing Functional Forms And Tables...

Nov 14, 2004

Hi,

I am a newbie at Access and am basically designing my first database. This database is for a short term project and is designed to track the attendance of employees at acompany. Here is a brief description of the tables and forms in question.

EmployeeInformation - this table stores records of each employee, their ID, DOB and SIN.

AttendanceProfile- this table stores records of prolonged absence periods for each employee. A given employee can have many attendance profiles, meaning that this table is linked to the EmployeeInformation table via a one-many relationship. This table will provide detailed information about the status and history of each Profile. So for example if an employee misses work for 12 days due to an appendicitis operation, the exact nature and dates of this absence would be listed as a new profile. The primary key for this table is an autonumber field called ProfileID

ActionLog - this table stores the actions taken by company employees (if any) in response to each AttendanceProfile. It is connected to the profiles table via a one-one relationship with ProfileID being the foreign key in this table. Another main field is the ProcedureNum field which will list the number of each procedure taken for a given ActionLog record. This table is needed to track what the company has done/is doing to track an employees prolonged absence.

Allow me to illustrate with an example. An employee, John Doe misses 15 days in June 2001 due to an illness in the family. An AttendanceProfile record is then made for this period illustrating the exact nature of Mr. Doe's absence as well as tracking what official documents he has submitted (eg medical note, official company documents). Another matching record containing the same ProfileID is also made in the ActionLog table describing what the company has done so far to track this absence. So if an HR employee calls Mr Doe's physician to verify this illness or sends a letter requiring further documentation, each of these steps is listed in this log for this absence profile.

Sorry for the long-winded explanation, but better now than to have to clarify myself later. Here is where I'm stuck. I would like to set up two data entry forms, to create new AttendanceProfile records and related ActionLog records. Obviously, these corresponding records are linked directly by the ProfileID field. After completing the AttendanceProfile form, I would like the user to be able to click a command button to open another form (I am avoiding a subform in this case because my attendanceProfile form is huge and I cannot conveniantly fit a subform on it) to open a new form where they can enter Procedure descriptions and dates on the ACtion log. For each new procedure the user enters, an autonumber fields automatically increments the procedureNumber for that specific ProfileID.

Finally, my question to any of you is, assuming that I have already designed the AttendanceProfile table and form, how shall I design the ActionLog table AND forms to accomplish this exact task.

Once again, sorry for the excessive detail. Your assistance is greatlys appreciated.

Regards,
Mike J.

View 1 Replies View Related

Tables :: Summation Of Fields In A Table Based On Query Results

Nov 5, 2013

I have a form that users can input data into and based on that data it runs a query and generates a report. These reports can be different based on user entered data on the form. My issue is within the report I would like to sum certain fields. The problem with trying to sum theses fields is that they show up on each row so I have hidden duplicates but when trying to sum the field it still trys to count the hidden duplicates thus giving a value that is of no use.

I have tried many methods to sum but one of the problems I continue to run into when I create a text box and build an equation and reference the field I would like to sum is when the report runs it is asking for a value to be entered for the field I am attempting to sum. I shouldn't need to enter a value as I am trying to obtain the value.

View 13 Replies View Related

Tables :: Use Insert Into Command To Insert Filepath Into Table That Adds Blank Label

Aug 28, 2014

I am at work, and I have acquired a database that prints labels. They now want the database to be coded so that after certain labels are printed the database will print a blank label. I have the code figured out as a Do While statement in order to print the blank label. The problem I am having is that I am trying to use the Insert Into command to insert the filepath into the table that adds the blank label.

|DoCmd.RunSQL "INSERT INTO Rod_tmakLabels ( Print, [Order] ) SELECT Yes AS Expr1, 'Rods Labels' AS Expr2"|

If I run the above command, it just adds the text "Rods Labels" at the end of the table. Is there anyway with the INSERT INTO command that I can insert the new label between the 2nd and 3rd row and add another row? Or is the command designed only to add a new row to the end? I haven't had any luck searching for this yet.

View 1 Replies View Related

INSERT Query - Insert New Data Only

Jul 2, 2010

Table TBL_NEWDATA is used to append new data to table TBL_PERSON_ALLOCATIONS.

TBL_NEWDATA { Person_ID, Department_ID }
TBL_PERSON_ALLOCATIONS { Person_ID, Department_ID, ... }

I need to devise a query to append data for a particular Department_ID from TBL_NEWDATA to TBL_PERSON_ALLOCATIONS where that data does not already exist there. i.e. for Department_ID 'Research', I would want to append 'Person_ID', 'Department_ID' (in this case: 'Research') to TBL_PERSON_ALLOCATIONS for any tuples not already held.

INSERT INTO TBL_PERSON_ALLOCATIONS (Person_ID, Department_ID)
SELECT Person_ID, Department_ID
FROM TBL_NEWDATA
WHERE TBL_NEWDATA.Department_ID='Form...'

[code]...

This Query takes a single argument from a control (Forms!Main!IN_Department), and this is the Department_ID to be updated.Is there any way to do this using a single query or will I have to use sub queries? I'd hoped not to as to keep the database as concise as possible.

View 2 Replies View Related

Should I Use DSUM?

Jul 30, 2007

I want to add to values based on if yes or no is selected in an option group.

My thinking is to use DSUM. When 'yes' is selected I want to grab a value from one field and add it to a value in another field giving a running total. I am currently using the following code but it throws back an error. Is DSUM the way to go?

Case 1

txtTotal.Value = DSum("[s1]", "[s2]")

View 3 Replies View Related

Using Dsum()???

Mar 29, 2008

Hi there guys, ill keep it short and snappy,

Im trying to use the Dsum() function to add together the "Quantities" of specific products bought in transactions i.e. the total quantity for a product called "red t-shirt" and the total quantity for another product called "blue t-shirt". the following was the code i tried to use but it just adds together all quantities of all products:

DSum("[Quantity]","Query2","[Product Name] =[Product Name]")

Does anyone have any ideas at all please?

Thanks

View 7 Replies View Related

DSUM() I Think!

May 17, 2005

Ok, I have a commercial database over which I have no control. It is ticket sales and I want to view them over time...

This is my table of transactions:

master_tix_header
tix_header_year
tix_header_performance_code
tix_header_no_seats - The number of seats sold
tix_header_first_transaction_date - The date of the transaction

The unique ID of the performance is made up of tix_header_year and tix_header_performance_code:

E.g.
In tix_header_year of 2004 there is a tix_header_performance_code of JSVH01 and in 2005 there is also JSVH01 - but there is never the same tix_header_performance_code more than once in the same tix_header_year...

Now I can get the number of tickets sold on each day using Sum() for a specific performance using:

SELECT SUM(tix_header_no_seats) AS TotalSeats, tix_header_first_transaction_date
FROM master_tix_header WHERE
tix_header_year = "2005"
AND tix_header_performance_code - "JSVH01"
GROUP BY tix_header_first_transaction_date;

This gives me:

TotalSeats tix_header_first_transaction_date
2 14/03/05
9 18/03/05
1 22/03/05

But what I want is:

TotalSeats tix_header_first_transaction_date
2 14/03/05
11 18/03/05
12 22/03/05

Can anyone give me any pointers?

I tried http://support.microsoft.com/kb/138911/ but it returned ambiguous results (seemed to reset the running total at the begining of each year...) or would say the query was too complex to run - I;ve probably missed something simple as I a newbie to the world of access/sql

TIA

Nick

PS: Access 97 if that makes any difference!

View 5 Replies View Related

DSum Help

Jul 5, 2005

I am trying to add up the total amnt under a certain location # under a certain representative #. What im having the query do it pull information from several different tables including the rep # and that rep #'s loc #. I want to find the sum of the sales under the location # for that rrep #. So it will look it up based on the loc # after it finds the rep #'s loc #. What would be the best way to do that.

View 1 Replies View Related

Dsum

Oct 2, 2006

Hi!
Can someone tell me why the following querie doesn't work?
txtcharges = DSum("[Charges]", "tblcharges", "[DateCharges] >= '" & startdate & "' AND [dateCharges] <= '" & enddate & "'") '

Thanks

JonyBravo

View 3 Replies View Related

Dsum... I Think!

Apr 23, 2007

Hi,

I have a table that contains Product, Manufacturer, Date and Cost and want to have a field that sums up totals based on criteria, for example, total cost for each manufacturer over a set period.

I think I need to use a dsum, but although I've tried to structure this query, I'm getting nowhere fast!

Any help is appreciated!!

P.s. I have no sql expereince, so please can any response not include a brilliant, but greek-to-me sql! :o

View 5 Replies View Related

Help With DSum

Jul 17, 2007

What do I do if wanting to sum my data in a table if it is text in the field that groups them together. In the examples, the grouping is by productID, but my grouping is by a text field.

DSum("[Amount Aus]","Costs","[Costs.Area]=" & [Costs.Area] And "[Costs.Project Code]=" & [Costs.Project Code]")

The Costs.Project Code is the text field. The Costs.Area part works fine, but not Costs.Project Code

Any help would be great

View 9 Replies View Related

DSum?

Jan 7, 2008

Hi Guys,
Look, I have a table to record supplier invoices for vehicle maintenance services.

The fields at this table are:

1. [Vehicle_License_Plate] - text - this is to input the vehicle ID, or registration
2. [Supplier_ID] - text - this is to input the supplier ID, or supplier code
3. [Invoice] - text - this is to input the supplier invoice number
4. [Invoice_Date] - date/time - this is to input the invoice date
5. [Service] - text - this is to input the type of service, from a pre-determined list
6. [Amount] - number - this is to input the invoice amount
7. [Accepted] - yes/no - this is to input whether the invoice has been accepted by our services or not
8. [Accounting] - date/time - this is to input the date when invoice has been booked in the accounting system

Furthermore, at my main vehicle table (the one where all the information respective to a vehicle is recorded), I have some fields where I need to have the total amount spent per service type (one field for each type of service).

In my intention to have an update query calculating the values for these fields, based on the supplier invoices table, I'm having a problem...

At the update query, I'm saying that I want to update i. e. field [Cost_Transportation], on my main vehicle table to the result of the following formula:

DSum("[Amount]";"DB_Supplier_Invoices";"[Service]='TRA'")

Problem is that, instead of having the total "Transportation" amount for the each vehicle well calculated and updated at the main vehicle database field, I'm getting the overall total transportation amount from the supplier invoices table, and this total amount is then updated on all [Cost_Transportation] fields at my main vehicle table.

Istead, what I would need was a formula that could calculate, from the "DB_Supplier_Invoices" table, the total [Amount] per service AND per vehicle, and then update the fields at the main vehicle table accordingly.

Any help will be highly appreciated!!
Should you require further clarification, please advise.
Many thanks and best regards.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved