Results 1 to 19 of 19

Thread: [RESOLVED] serial no in datareport

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    169

    Resolved [RESOLVED] serial no in datareport

    Hi friends,

    How to generate automatically serial nos. in datareport.
    Suppose if it displays 100 employee's payment report,serial no.should be generated from 1-100.Please help me?

  2. #2
    Fanatic Member amrita's Avatar
    Join Date
    Jan 2007
    Location
    Orissa,India
    Posts
    888

    Re: serial no in datareport

    Add a autonumber field to the table and bind that to the Serial Number

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    169

    Re: serial no in datareport

    Thanks.
    Is it possible if we merge two tables also?Please explain how to do!

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    169

    Re: serial no in datareport

    But if we want to print report for deptwise,can we use auto serialno?

  5. #5
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: serial no in datareport

    instead you can consider generating Serial Number at the query result itself...
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  6. #6
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: serial no in datareport

    How are you setting up the report at the moment? Through the data environment or at run-time through set datasource = recordset? And what's the SQL that fills the command object/recordset?

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    169

    Re: serial no in datareport

    using query,how to generate ?Please give one example.

    Code:
    vb Code:
    1. Private Sub cmdOk_Click()
    2.     On Error Resume Next
    3.     If Txtdate = "" Then
    4.         flag = MsgBox("Display Entire Issued Report?", vbYesNo + vbQuestion, "Materials System")
    5.         If flag = vbYes Then
    6.             If Rs.State = adStateOpen Then
    7.                 Rs.Close
    8.             End If
    9.             Rs.open "Select * from Sale where qty>0", conn
    10.             Set IssdateReport.DataSource = Rs
    11.             Load IssdateReport
    12.             IssdateReport.Show
    13.             Unload Me
    14.         Else
    15.             Exit Sub
    16.             Txtdate.SetFocus
    17.         End If
    18.     Else
    19.         If Rs.State = adStateOpen Then
    20.             Rs.Close
    21.         End If
    22.         Rs.open "select * from Salesnew where date between '" & Txtdate.Text & "'and '" & txtdateto.Text & "'", conn
    23.         Set IssdateReport.DataSource = Rs
    24.         Load IssdateReport
    25.         IssdateReport.Show
    26.         Unload Me
    27.     End If
    28. End Sub

  8. #8
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: serial no in datareport

    I see your getting a subset based on dates... you might want to read this first http://www.vbforums.com/showthread.php?t=450993 and decide if its feasible or not to pursue a subquery solution.

    You can also try printing out your data with Excel or a better reporting tool since the data report is too basic.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    169

    Re: serial no in datareport

    Thanks.
    Is it possible to include serial no. in datareport through data environment?

  10. #10
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: serial no in datareport

    Is the serial number the number of the record in the report, or is it the number of sale? (IOW, should a particular sale have the same serial number every time it appears on a report, or should the numbers start over for each report?)
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  11. #11

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    169

    Re: serial no in datareport

    Thanks.
    Serial number should come according to the no.of rows retrieved for that particular report.

    For example,if we want to display the no.of employees(ex.125 emp.) in a particular dept. , serial no.s should be generated from 1-125 in a report.

  13. #13
    Fanatic Member amrita's Avatar
    Join Date
    Jan 2007
    Location
    Orissa,India
    Posts
    888

    Smile Re: serial no in datareport

    I think the only way to add a serial number is to make it a part of the query.Check this
    Code:
    SELECT (select count(a2.emp_no) from tblEMP as a2 
    where a1.emp_no<=a2.emp_no) AS [SL No], 
    a1.name, a1.address FROM account AS a1 
    GROUP BY a1.emp_no, a1.name, a1.address
    ORDER BY a1.emp_no DESC

  14. #14
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: serial no in datareport

    Yes amrita, as an aggregate query (count) that is a subquery... for a1.emp_no<=a2.emp_no to work properly as intended, refer to link in post #8... also, such an implementation will also involve additional overhead moreso with lots of returned records.

  15. #15
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: serial no in datareport

    Quote Originally Posted by Akshaya
    using query,how to generate ?Please give one example.
    Check my signature for "Add Serial Number / Row Number to SQL Queries" to add serial / row number to a query
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    169

    Re: serial no in datareport

    Thanks friends.
    I used the following query.It is working fine.
    But Serno comes in desc order by default.How to arrange in asc. order?

    Code:
    SELECT Code, Name, grade,remarks,(SELECT COUNT(*) FROM Customer C2 WHERE C2.code >= C.Code) AS SerNo FROM Customer C

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    169

    Re: serial no in datareport

    Thanks friends.It is working fine in this code.

    Code:
    SELECT code, name, grade,remarks,(SELECT COUNT(*) FROM Customer C2 WHERE C2.Code >= C.Code) AS SerNo FROM Customer C  order by c.code desc

  18. #18
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: serial no in datareport

    Quote Originally Posted by Akshaya
    Thanks friends.It is working fine in this code.

    Code:
    SELECT code, name, grade,remarks,(SELECT COUNT(*) FROM Customer C2 WHERE C2.Code >= C.Code) AS SerNo FROM Customer C  order by c.code desc
    Thanks for sharing the solution

  19. #19
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: [RESOLVED] serial no in datareport

    Akshaya: if you change the greater than symbol in the query to lesser than symbol it would give you the result what do u want...

    for more explanation please refer this
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width