Solved

Getting Weekly reports

Posted on 1998-12-10
1
200 Views
Last Modified: 2010-05-03
I have a random access database with dates. I would like to do a weekly report but I am stuck on how to translate from dates to weeks. I am using VB4-16 bit.
Any Thoughts...
With code please...
0
Comment
Question by:dtucker
1 Comment
 
LVL 1

Accepted Solution

by:
Eklipse earned 100 total points
ID: 1449375
I suggest this code.With it ,you'll obtain the week's limits and then you can build the reports.
Note: I don't have a way to know if the commands DatePArt and DateAdd exist in VB4
If they don't ,this answer is useless...

Steps:
Create a new project,drop this code:

Option Explicit

Private Sub Form_Load()
Dim First As Date, Last As Date
GiveMeWeek Now(), First, Last 'Now is a parameter value by example.

End Sub

Sub GiveMeWeek(DaySearch As Date, FirstDayWeek As Date, LastDayWeek As Date)
Dim Daynumber%
Daynumber = DatePart("w", DaySearch) 'Give me the day number within the week
'So,we can calculate the first day of this week with...
FirstDayWeek = DateAdd("d", -Daynumber, DaySearch)
'and the last
LastDayWeek = DateAdd("d", 7 - Daynumber, DaySearch)
'Note:weeks are from Sunday to saturday.In other countries,weeks are from monday to 'sunday.to adapt to other country,I think that you have to add 1 to daynumber
End Sub

I hope this helps you
Good Luck
Fer
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

860 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