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

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 1763
"Geoff" <gf****@freenetname.co.uk> wrote in message
news:7L******************************@brightview.c om...
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****@freenetname.co.uk> wrote in message
news:7L******************************@brightview.c om...
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****@freenetname.co.uk> wrote in message
news:n5********************@brightview.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****@freenetname.co.uk> wrote in message
news:7L******************************@brightview.c om...
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(strSessionCode 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
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";...
1
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...
3
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...
4
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...
1
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...
17
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...
8
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...
26
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...
11
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
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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...

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.