473,836 Members | 1,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

struggling with a query

I need to produce a report based on a query.

Cost is a calculated field and its value is dependent on another field, in
the query, called Session.

There are 5 different Session codes each generating a different Cost.

What is the simplest way to set the correct Cost, in this calculated field,
when there are so many options for a Session ?

Any help will be genuinely appreciated

Geoff
Jan 9 '06 #1
4 1788
"Geoff" <gf****@freenet name.co.uk> wrote in message
news:7L******** *************** *******@brightv iew.com...
I need to produce a report based on a query.

Cost is a calculated field and its value is dependent on another field,
in the query, called Session.

There are 5 different Session codes each generating a different Cost.

What is the simplest way to set the correct Cost, in this calculated
field, when there are so many options for a Session ?

Any help will be genuinely appreciated

Geoff

We don't know much about the tables and fields in your database - so for all
we know the solution might be quite easy or be pretty complex.
It might be that you should have a table listing which session code has
which cost - then your query could join both tables and calculate the cost.
It might be that the cost calculations are very complex and cannot be done
without calling vba functions from your query.
You could let us know further details.

Jan 9 '06 #2
Many thanks for taking the trouble to reply. Yes it was obvious when you
suggested using a extra lookup table and incorporating this into the query -
I am a bit on the slow side really

However I don't understand your comment about calling VBA code from the
query. How do you do that?

Geoff


"Anthony England" <ae******@oops. co.uk> wrote in message
news:dp******** **@nwrdmz03.dmz .ncs.ea.ibs-infra.bt.com...
"Geoff" <gf****@freenet name.co.uk> wrote in message
news:7L******** *************** *******@brightv iew.com...
I need to produce a report based on a query.

Cost is a calculated field and its value is dependent on another field,
in the query, called Session.

There are 5 different Session codes each generating a different Cost.

What is the simplest way to set the correct Cost, in this calculated
field, when there are so many options for a Session ?

Any help will be genuinely appreciated

Geoff

We don't know much about the tables and fields in your database - so for
all we know the solution might be quite easy or be pretty complex.
It might be that you should have a table listing which session code has
which cost - then your query could join both tables and calculate the
cost. It might be that the cost calculations are very complex and cannot
be done without calling vba functions from your query.
You could let us know further details.

Jan 9 '06 #3
Br
Geoff wrote:
I need to produce a report based on a query.

Cost is a calculated field and its value is dependent on another
field, in the query, called Session.

There are 5 different Session codes each generating a different Cost.

What is the simplest way to set the correct Cost, in this calculated
field, when there are so many options for a Session ?

Any help will be genuinely appreciated

Geoff


Why not create a simple list query and do the summing etc on the report?
(ie. add an entry under Sorting and Grouping for Session, set the option
to have a Session footer, add a calculated field to sum the values).
--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Jan 9 '06 #4
"Geoff" <gf****@freenet name.co.uk> wrote in message
news:n5******** ************@br ightview.com...
Many thanks for taking the trouble to reply. Yes it was obvious when you
suggested using a extra lookup table and incorporating this into the
query - I am a bit on the slow side really

However I don't understand your comment about calling VBA code from the
query. How do you do that?

Geoff


"Anthony England" <ae******@oops. co.uk> wrote in message
news:dp******** **@nwrdmz03.dmz .ncs.ea.ibs-infra.bt.com...
"Geoff" <gf****@freenet name.co.uk> wrote in message
news:7L******** *************** *******@brightv iew.com...
I need to produce a report based on a query.

Cost is a calculated field and its value is dependent on another field,
in the query, called Session.

There are 5 different Session codes each generating a different Cost.

What is the simplest way to set the correct Cost, in this calculated
field, when there are so many options for a Session ?

Any help will be genuinely appreciated

Geoff

We don't know much about the tables and fields in your database - so for
all we know the solution might be quite easy or be pretty complex.
It might be that you should have a table listing which session code has
which cost - then your query could join both tables and calculate the
cost. It might be that the cost calculations are very complex and cannot
be done without calling vba functions from your query.
You could let us know further details.


There are some calculation which cannot be done with simple lookup tables.
Then you could create a new code module and write a function like this:

Silly example:

Public Function GetCost(strSess ionCode As String) As Currency

Dim curCost As Currency

If strSessionCode = "CodeOne" Then
curCost = 1.42
Else
curCost = 1.94
End If

GetCost = curCost

End Function
Once the module is saved, you can call it directly from your query, eg:

SELECT MyTable.ID, MyTable.Session ,
GetCost([Session]) AS Cost FROM MyTable
Jan 9 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
7307
by: Paul Charlton-Thomson | last post by:
Hi, I am trying to execute 2 queries and then output the results in 2 loops but maybe I'm using the wrong approach. Can anyone help me here ... $query_1 = "SELECT field_1 FROM table_1"; $result_1 = mysql_query($query_1) or die(mysql_error());
1
2594
by: Joshua Beall | last post by:
Hi All, I have a task that should be very simple but I'm running into trouble. All I want to do is query a document using XPath, and save the resulting XML in a string. Here's that I am trying (PHP5): // $xml has the entire XML document in it; I included it for reference at the end of the document $dom = new DOMDocument(); $dom->loadXML($xml);
3
8854
by: Newbie | last post by:
I am a newsbie to ASP but need to get a script together that will insert the Windows Username of the local machine into an access database. I get the errors from my code below, can anyone help me please as I've hit a deadend: Thanks CODE:
4
2006
by: Rowan | last post by:
Hi there, it's me again. I am having trouble with a view again. I am trying to do a calculation, but there are some checks that need to be taken into consideration. Maybe a view is not the right way to deal with this. I don't know. This is the beginning of my query. SELECT coalesce(f.filenumber, i.filenumber) as filenumber, i.InvoiceNumber, i.InvoiceValue, il.lineid, MPF = .21 * (il.UnitCost * il.UnitQty + il.AddMMV - il.MinusMMV -...
1
1452
by: ROBERT BEE | last post by:
Below is some code I have copied from the web with the intention of modifying but I keep getting the stated errors. This is the umpteenth attempt at trying to get OleDbConnection,OleDbDataAdapter to work without any success. Do the references have a hierarchy like in vb6 or is there something else I am missing? Many Thanks in advance
17
4828
by: Milkstr | last post by:
I have 2 tables that hold similair information, i have a query running off then to total up the sum of a couple of colums, i want to run another query that will create a colum that holds the 2 of the first query colums divided by each other if that makes sense, I thought it was as simple as e.g. colum1: query1.SumOfGoals / query1.SumOfApperances but this doesn't work, can anyone help!!!!
8
2543
by: Keith | last post by:
I try to learn SQL by figuring out things. I want to make a listing of all records that were changed in the last... 1, 6, 12 hours/days. I have a field called 'updated' managed like: UPDATE tablename SET updated = NOW(), .... WHERE.... I created a query like this: "SELECT * FROM tablename WHERE 'updated'
26
2606
by: mark | last post by:
The idea of this is very simle. The site is 800px wide and sits in the middle of the browser window, on either side of the site I want a different background image aligned against it. If I were doing this with table based layout the code would be as follows: <head> <style type="text/css"> #bgleft { background: url(left_half_circle.gif) right top repeat-y;
11
22886
by: briankind | last post by:
Hello i have these radio buttons and i wish to have the corresponding textboxes to be visible when the radiobutton is selected. any Help? snippets. thanks thanks in adv Bry
0
9671
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
10854
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10558
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10600
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10257
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...
0
9387
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7794
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
6981
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();...
3
3116
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.