Login    Forum    Register    Search    FAQ

Board index » HELP AND ADVICE » GAME/SOFTWARE/HARDWARE PROBLEMS




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: working out %ages in acces?
 Post Posted: Sun Apr 09, 2006 9:06 pm 
Offline
I Burn Insects
User avatar

Joined: Sat May 01, 2004 11:13 pm
Posts: 2132
Location: Grimsby - At home
i have this i have made,

http://rapidshare.de/files/17600419/Vil ... l.zip.html

there are 4 time slots, morning, afternoon, evening and evening extension. these can be used by the ID 1,2,3,4 respectivly.

There are bookings most days and i need to be able to bring up a box and select a month like i have in my "invoice" report. it then, depending on the month selected, needs to create a form that shows monday to sunday and a % of these days sued throught that month!

so i need to create a report that looks up every single time slot on every day and shows all 7 days and their percentage of usage.

So i get something that looks like this for january and february in a access form,(snazzy colours not needed;) )

Image

This is needed as i need to learn how this is done for the exam, the exam consists of questions on this project and we have to answer questions on how we made it and exactly what we did!

so i need to know how i can do this please, i have tried myself but all i can do is create a form with the days all ready i dont know the code to put in to get %ages!!!!

Thanks for any help here!

_________________
Image


Top 
 Profile  
 
 Post subject:
 Post Posted: Mon Apr 10, 2006 7:22 am 
Offline
Pure sex on legs

Joined: Thu Mar 04, 2004 4:45 pm
Posts: 583
Location: Zummerzet, UK
so to clarify:

your program needs to know:
1. how many days there are in the current month
2. what day of the week any particular date might be (or is that data already stored in your table ?)
3. you'll then need a few queries which feed into another query (which is then the datasource for your form/subform)
- try looking at the SQL Domain Agregate Functions help in Access, in particular SELECT COUNT([idField]) WHERE WeekDay([myDateField]) = 1
- so you'll also want to look up Access Date functions (for the WeekDay() bit)

PS
I'm guessing missing Friday out from your piccy was just a typo ??
:)


Top 
 Profile  
 
 Post subject:
 Post Posted: Mon Apr 10, 2006 9:43 am 
Offline
I Burn Insects
User avatar

Joined: Sat May 01, 2004 11:13 pm
Posts: 2132
Location: Grimsby - At home
yer friday was a typo, i have a qurey that lets ne picj a certain month, not i just need to get this thing to sort out each day and give me a %age of each time slot :( Too hard this!

_________________
Image


Top 
 Profile  
 
 Post subject:
 Post Posted: Tue Apr 11, 2006 7:10 am 
Offline
Pure sex on legs

Joined: Thu Mar 04, 2004 4:45 pm
Posts: 583
Location: Zummerzet, UK
I don't believe you can use loops in JET SQL (Access's query language). You could write a query using recordsets in the form's code (VBA) and loops through that way, but that'll perform quite slowly.

SELECT COUNT gives the number of rows which match some criteria

so you need several SELECT COUNT queries to find out how many records meet each criteria, then an uber query to gather all those results into one set of data to present it to your form. Or you could do it in one nested query.

So that leaves you with writing several different queries each of which give you an element of your final result.

Have you covered Recordsets or SQL in your course ?
(wouldn't want to give you help finding an answer you wouldn't know from your course :) )

SELECT Item, Count(Item) AS Tally FROM Products
GROUP BY Item;

Will give one row for each item type with a count next to it...
that helping ? :)


Top 
 Profile  
 
 Post subject:
 Post Posted: Tue Apr 11, 2006 11:23 am 
Offline
I Burn Insects
User avatar

Joined: Sat May 01, 2004 11:13 pm
Posts: 2132
Location: Grimsby - At home
wow really helpful post, ill try it, though im not 100% whats quite going one, lol.

btwno i havent covered Recordsets or SQL in my course, hardly any of the stuff im doing tbh. Thanks for the help so far, ill see if i cna do this today, though doubt it, because i need to learn what im doing for the exam. Thanks again!!! :D

_________________
Image


Top 
 Profile  
 
 Post subject:
 Post Posted: Wed Apr 12, 2006 9:04 am 
Offline
I Burn Insects
User avatar

Joined: Sat May 01, 2004 11:13 pm
Posts: 2132
Location: Grimsby - At home
well i tried it!

i have the count query done, i get either 1,2,3 or 4 for each date, now how do i work the %age in a form in access or do i need to run a query and tell it something like when 4 =100% when 3=75% etc? But how on earth would you do that!

Im thinking it must be fairly easy as its out of 4 so is there some code i need?

Thanks for the continued help!

_________________
Image


Top 
 Profile  
 
 Post subject:
 Post Posted: Wed Apr 12, 2006 11:29 am 
Offline
Pure sex on legs

Joined: Thu Mar 04, 2004 4:45 pm
Posts: 583
Location: Zummerzet, UK
It's always better, more efficient and ultimately easier to do as much of the number-crunching in the SQL and just let the form concentrate on the shiney stuff.

Is the maximum possible 4 ?

If it is then your query just needs to have something like

SELECT 100/(SELECT COUNT(myField) FROM myTable) as MyPercentage

If it isn't then you need to do a more complicated sum something like

(Actual Count / Maximum Possible) * 100


Top 
 Profile  
 
 Post subject:
 Post Posted: Wed Apr 12, 2006 4:53 pm 
Offline
I Burn Insects
User avatar

Joined: Sat May 01, 2004 11:13 pm
Posts: 2132
Location: Grimsby - At home
i did this, and i get an "error -3005 no error is defined ....."

Image

_________________
Image


Top 
 Profile  
 
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 8 posts ] 

Board index » HELP AND ADVICE » GAME/SOFTWARE/HARDWARE PROBLEMS


Who is online

Users browsing this forum: No registered users and 35 guests

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
  • Shoutbox
  • Shout Message


test
cron