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?

Recommended Answers

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 …

Jump to Post

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 …

Jump to Post

All 5 Replies

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.

another approach is to compare to a formatted string something like

format$(tranDate,"mmm-yyyy") = "jan-2012"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.