I developed a pay roll [/B]application for my organization, I want to create a monthly report for the employees but I want it inform of querying the database(data file) to generate a report for two different months(like January and December)on a single report sheet, PLEASE HOW CAN I ACHIEVED THIS?

6 Years
Discussion Span
Last Post by ChrisPadgham

You create a query statement based on the dates you want to report on.

You must input that data using some type of date control--which would probably be best. Or you can have the user type in the date he wishes to query. But that leaves you open to date format errors.


Yes, it shields light to my way out. Now, the new question is how can i create a query to generate specific monthly report? Please Help urgently


You use the same method as described before. But you have to use code to determine the first and last day of the required month.

Thirty days hath September,
April, June, and November;
All the rest have thirty-one,
Save February, with twenty-eight days clear,
And twenty-nine each leap year.

You can use a Select Case Statement to set up a string for the number of Days, and then you have to use the appropriate value with the year for your SQL Query.

Private Function ReturnDateQuery (ByVal MyDate as Date) as String
Dim strSQL as string 
Select Case Month(MyMonth)

Case 2 ' February

Case 5, 6, 9, 11 ' April, etc.

Case else

End Select 

' Write code to include first and last day of month and the particular year to return the proper SQL string.
ReturnDateQuery = strSQL
End Function

it is possible to design such report provided you use either datareport or crystal report.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.