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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable Rates of pay applicable between certain dates

Status
Not open for further replies.

Samulayo

Programmer
Aug 13, 2002
46
0
0
GB
Overview: to have variable rates for generating a report in Access 97


Detail:

I am designing a timesheet organisation database, whereby users can enter their timesheets for the week etc. in one FE, and then the administrators can review the timesheets, accept/reject them, and produce reports using the data from the submitted timesheets in another FE. ie.

|User FE| --> |datastore| <-- |Admin FE|

The problem I’ve reached is with the rate of pay for each staff member. As historical reports need to be able to be produced, then a table of staff rates and their applicable dates.
(RateID, StaffID, Rate, start date, end date)

And has the relationship :

|Rate| >--- |Personnel| ---< |TimeSheet|

where ---< indicated one-to-many

There are physically 8 different reports that can be run (the user will see as 21 different reports). All reports have a format similar to:-

Name, Agency, Discipline, Date, WeekNo, Year, Total, Cost

Whereby cost is generated using the staff member’s rate and multiplying it by the number of hours worked.

The Rate needs do be found by comparing the date of the timesheet, and finding which rate of pay was applicable for that timeframe. I have been able to produce this on a single form using a combobox that runs a query where the start date criteria is <=([forms]![#test1].[date]) and end date criteria is >=([forms]![#test1].[date])

However, this cannot be reproduced with either continuous forms or a report as the first result from the combobox is replicated throughout the report.

One thought that I had was to create a table using the data from the form, but I do not know how to do this as I have had no experience with make table queries, therefore cannot see a straight forward way of doing this.

If this cannot be completed in Access97, but can in access XP, then I will persuade the company that 2 copies of XP will be required (as only 2 people will be using the admin FE)

Any help with is matter will be greatly appreciated, and if any more detail, or a cut down copy of the database is required, then please just post a reply.

Regards

Samulayo
 
Try a correlated sub-query ...

SELECT p.[Name], (SELECT Rate FROM tblRate WHERE StaffID = p.[StaffID] AND t.SheetDate BETWEEN StartDate AND EndDate) AS Rate FROM Personnel p INNER JOIN TimeSheet t ON p.StaffID = t.StaffID

BTW: I have used aliasing to keep the statement short. I have called the TimeSheet date SheetDate - I think you used 'Date' which is a reserved word - if you want to keep it like that, use 't.[Date]'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top