Solved

Access roster view

Posted on 2011-03-08
3
715 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
3 Comments
 
LVL 8

Accepted Solution

by:
Andrew_Webster earned 125 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 125 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sending email from List Data 2 51
Reset Active Directory Password via MS Access 9 54
ms access 2013, running .mdb 2 31
I need to be able to get MAX(date)-1 from table. 4 26
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now