Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 101 ? 1

Status
Not open for further replies.

rdjohnso

Programmer
Mar 30, 2001
67
US
Still very new to this VB Module coding thing.... need point in the right dir.

I have a report with a need to populate a grid of information using 2 other modules I've written....
Goal: I need to cumlitivly get totals per month of persons hours and cost grouped by organization....

I have a table: tbl_Person with every employee and has their Organization
stored in there as a string....(may not be best normalized but have reasons why)..

I have a module that will get a single person's hours for a given month
and another module that willt ake those hours and get their cost for
same month.

I figure if I get a DISTINCT list of Organizations and then loop that around the Person table ... calling the Hours and Rate modules... I can get total hours and cost per month groupe by Organization...

Here is the code I started..... not even sure how to create or add to an array in Access... any help would be appreciated!!!

--------------------------------------------------------------------
Option Explicit

'Get Total running Hours for currentHours and nextHours
Public mPersonID As Integer

'Get Array of Person ID's grouped by Organization'
Public Function ResourceForecast() As Integer

Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rsResourceData As ADODB.Recordset
Dim sConnString As String
Dim iCtr As Integer
Dim iOrg As String

sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & CurrentProject.Path & "\Blue&White.mdb;"

conn.Open sConnString
Set cmd.ActiveConnection = conn

cmd.CommandText = "SELECT DISTINCT Organization FROM tbl_Person"
cmd.CommandType = adCmdText
Set rsResourceData = cmd.Execute

'Outside Loop - get Distinct list of Orgaization's
Do While Not rsResourceData.EOF
For iCtr = 0 To rsResourceData.Fields.Count - 1
'OutPuts Name and Value of each field
Debug.Print rsResourceData.Fields(iCtr).Name & ": " & _
rsResourceData.Fields(iCtr).Value

'** CREATE An Array called iOrg
iOrg = rsResourceData!Organization

Next


'Inside Loop - get/add to person hours and cost modular variable

'** Use this new array to loop over persons while calling the other 2 functions 1) PersonHrs(PersonID, StartDate, EndDate) and 2) PersonCost(PersonID, PersonHrs, StartDate, EndDate) to get my data


Loop

End Function
 
Is this correct for a year. The organization names are listed alphabetically. I replaced the Names with A, B, C to protect the innocent. So your first name has a key of A

Month OrgKey PersonHrs PersonCost
Jan A 826 $103,250.00
Jan B 8617 $993,125.00
Jan C 11369 $1,379,125.00
Jan D 878 $109,750.00
Jan E 618 $76,375.00
Jan F 1258 $157,250.00
Jan G 2922 $267,750.00
Feb A 1492 $186,500.00
Feb B 9766 $1,144,750.00
Feb C 12912 $1,576,000.00
Feb D 914 $114,250.00
Feb E 541 $67,625.00
Feb F 2286 $285,750.00
Feb G 4875 $533,375.00
Mar A 1950 $243,750.00
Mar B 12025 $1,411,125.00
Mar C 17124 $2,117,500.00
Mar D 1049 $131,125.00
Mar E 650 $81,250.00
Mar F 3174 $396,750.00
April A 896 $112,000.00
April B 10496 $1,232,000.00
April C 15936 $1,972,000.00
April D 752 $94,000.00
April E 576 $72,000.00
April F 2680 $335,000.00
April G 4856 $527,000.00
May A 634 $79,250.00
May B 11677 $1,371,625.00
May C 18874 $2,337,250.00
May D 651 $81,375.00
May E 646 $80,750.00
May F 2948 $368,500.00
Mar G 5977 $655,125.00
May G 5140 $554,500.00
Jun A 0 $0.00
Jun B 11607 $1,362,875.00
Jun C 19114 $2,367,250.00
Jun D 475 $59,375.00
Jun E 646 $80,750.00
Jun F 2948 $368,500.00
Jun G 4182 $434,750.00
Jul A 0 $0.00
Jul B 10600 $1,245,000.00
Jul C 17904 $2,218,000.00
Jul D 272 $34,000.00
Jul E 576 $72,000.00
Jul F 2680 $335,000.00
Jul G 1120 $60,000.00
Aug A 0 $0.00
Aug B 12098 $1,420,250.00
Aug C 20810 $2,578,250.00
Aug D 313 $39,125.00
Aug E 650 $81,250.00
Aug F 2714 $339,250.00
Aug G 1288 $69,000.00
Sep A 0 $0.00
Sep B 11047 $1,296,875.00
Sep C 19001 $2,354,125.00
Sep D 286 $35,750.00
Sep E 611 $76,375.00
Sep F 2310 $288,750.00
Sep G 1176 $63,000.00
Oct A 0 $0.00
Oct B 11572 $1,358,500.00
Oct C 19906 $2,466,250.00
Oct D 299 $37,375.00
Oct E 646 $80,750.00
Oct F 2420 $302,500.00
Oct G 1232 $66,000.00
Nov A 0 $0.00
Nov B 10520 $1,235,000.00
Nov C 18096 $2,242,000.00
Nov D 272 $34,000.00
Nov E 576 $72,000.00
Nov F 2200 $275,000.00
Nov G 1120 $60,000.00
Dec A 0 $0.00
Dec B 10520 $1,235,000.00
Dec C 18096 $2,242,000.00
Dec D 272 $34,000.00
Dec E 576 $72,000.00
Dec F 1880 $235,000.00
Dec G 1120 $60,000.00
 
wow, had no idea you would put in that much effort.....

thanks a bunch... will give it a try...

R
 
OK Majp..... here's the big ?...
It looks like the data is correct, super thanks...

I have to call these queries in my control Source for each cell... so if you go to the following Report..... 'Grpt_ResourcePlanning' you will c the cells
I have to popuate a cell for a specific group for a given month / current yr....

I have used DLookup() in some of the other cells.... but how might I do it with the queries u listed?

Heres an example of DLookup I used in another cell on the report...

=DLookUp("[BudgetAmount]","rtbl_Budget","[BudgetTitle] = 'GW Business' AND Month([BudgetTimePeriod]) = '1' AND Year([BudgetTimePeriod]) = " & Year(Date()))

Thanks a vbunch... Stars for all ur help,

Ron
 
PS... Email me if your willing....

lardj2332 <at> adelphia.net....

Are you avail via one of the IM Services? If so, which?
 
MajP.

I am trying to reply to the email u sent me and it gets bounced... do u have another email address that u can send to me so I can respond? Are you avail via IM to chat?

Thx for ur help,

Ron
 
MajP..
you repliesd to me but didnmt give me an alt email addy...

Pls do, Thx

Ron
 
Ron,
I looked at the PersonCost function, and I do not understand the rule. I do not think it is doing what you want it to do. Unless I am missing something, the way you have it set up it looks to see if the person has a rate that falls within the reporting period (does not matter if there is two rates in that period, it only returns the first one). If a rate exists in that period the person gets the first rate for the entire period.
What is the real rules you want to execute? Because what you have is this.

"if there is a any rate period within the period of interest then get the first rate listed for the entire period"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top