in datareport i'm getting multiple rows i want only selected row in datareport

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pramodrepaka
    New Member
    • Mar 2007
    • 21

    in datareport i'm getting multiple rows i want only selected row in datareport

    I am using Vb6. I am using data report in my program I have it working but when I print it is printing all the records in the database. I am having troubles with it printing a single record. with the help of dataenvironment . If there is anyone out there that has had this same problem and know how to correct it. I would really appreciate it thank you for your time
  • cmrhema
    Contributor
    • Jan 2007
    • 375

    #2
    Originally posted by pramodrepaka
    I am using Vb6. I am using data report in my program I have it working but when I print it is printing all the records in the database. I am having troubles with it printing a single record. with the help of dataenvironment . If there is anyone out there that has had this same problem and know how to correct it. I would really appreciate it thank you for your time
    I would suggest to work without data environment.
    Include just the datareport
    Now design your data report
    Place the textboxes on the Detail section
    Name the textboxes exactly the same you have named the data
    eg you have a table name emp which consists of
    empno,empname,e mpadd,empsalary ,empjoindate
    Now in the datafield of the textboxes name the same as above.

    Now your question of printing a single record
    You certainly must have at least one of the datafield which contains unique data

    Code it as below
    Dim db_file As String
    Dim Mycon1 As New ADODB.Connectio n
    Dim m1 As New ADODB.Recordset
    ' Get the data.
    db_file = App.Path
    If Right$(db_file, 1) <> "\" Then db_file = db_file & "\"
    db_file = db_file & "emp.mdb"

    ' Open a connection.

    Mycon1.Connecti onString = _
    "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
    "Data Source=" & db_file & ";" & _
    "Persist Security Info=False"
    Me.Refresh
    Mycon1.Open
    Set m1 = Mycon1.Execute( "select empno,empname,e mpadd,empsalary ,empjoindate where empno='" & Text1.Text & "'", , adCmdText)
    ' Here Text1.Text will be the empno . If it is only number then remove the single quotes after empno and &(ampersand) also do not forget to include val before Text1.Text
    ' Connect the Recordset to the DataReport.

    Set DataReport1.Dat aSource = m1
    DataReport1.Win dowState = vbMaximized
    DataReport1.Sho w vbModal
    DataReport1.Cap tion = "Employee Details"
    m1.Close
    Mycon1.Close
    Set Mycon1 = Nothing
    End If

    Try it out and let me know

    Comment

    Working...