?
Solved

Access roster view

Posted on 2011-03-08
3
Medium Priority
?
727 Views
Last Modified: 2013-11-28
Hi,
I have a database for all staff job allocations for my work using MS Access 2007/2010 asthe frontend. There is a record created each date a member of staff is placed on a job. It would be really useful to be able to display the dates for an entire month showing which jobs somebody is assigned to. At the moment i have some VBA code which runs through the entire month checking each day to see if there is a job assigned and creating a blank, dummy record if it isnt. This is very slow and cumbersome and doesnt allow quick updating of the records. Is there a better way of doing this?

Many thanks,
Chris
0
Comment
Question by:chrisryan43
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Accepted Solution

by:
Andrew_Webster earned 500 total points
ID: 35069219
Yes there is.

Create a dates table.  The quick way to do this is to use Excel: enter the first couple of dates then select them and drag down to create a whole list of dates.  Copy this into a table in Access.

Now create a query - the key is the OUTER JOIN - that shows what you want.

Something like:

SELECT roster.staffmember, dates.thedate FROM roster LEFT OUTER JOIN dates ON roster.thedate = dates.thedate.

This will show "staffmember" that has a "thedate" matched in "dates" and every "thedate" from dates regardless of whether it's matched in "roster".  Does that make sense?

(I've used "thedate" as "date" is a reserved word, and it's good practice to avoid naming table fields with reserved words.)
0
 
LVL 31

Assisted Solution

by:Helen Feddema
Helen Feddema earned 500 total points
ID: 35069821
You can use the DateAdd function in Access to create a table filled with incrementing dates.  Here is some code that fills a table with incrementing month-year values; you can modify it to create dates, just incrementing by day instead of month.
'Clear MonthYear table
   strMonthYearTable = "zstblAllMonthYears"
   strSQL = "DELETE * FROM " & strMonthYearTable & ";"
   DoCmd.SetWarnings False
   DoCmd.RunSQL strSQL
   
   strCurrentYear = Year(Date)
   strCurrentMonth = Month(Date)
   
   dteStart = DateAdd("m", -13, Date)
   dteEnd = DateAdd("m", 12, Date)
   Debug.Print "Date range: " & CStr(dteStart) & " to " & CStr(dteEnd)
   
   Set dbs = CurrentDb
   Set rst = dbs.OpenRecordset(strMonthYearTable)
   
   For intMonth = 1 To 24
      dteDynamicMonth = DateAdd("m", intMonth, dteStart)
      strMonthYear = Year(dteDynamicMonth) & "-" & Format(Month(dteDynamicMonth), "00")
      'Add a record to month-year table
      rst.AddNew
      rst![MonthYear] = strMonthYear
      rst.Update
   Next intMonth
      
   rst.Close

Open in new window

0
 

Author Comment

by:chrisryan43
ID: 35085124
Amazing! Thankyou so so much!

All working beautifully now
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question