Dear Sir,
I have try to preview the data report after search criteria with textbox and button and the datareport is showing all the records in datareport. I just want to view only one records from database to datareport.
I have try to preview the data report after search criteria with textbox and button and the datareport is showing all the records in datareport. I just want to view only one records from database to datareport.
Code:
Private Sub cmdpreview_Click()
Dim conRpt As ADODB.Connection
Dim rs_rpt As ADODB.Recordset
Dim sql As String
Set conRpt = New ADODB.Connection
Set rs_rpt = New ADODB.Recordset
conRpt.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Test.mdb;Jet OLEDB:Database Password=123"
sql = "Select * from test where [ID] Like '" + txtidno.Text & "%'"
rs_rpt.Open sql, conRpt, adOpenDynamic, adLockOptimistic
With DataReport1.Sections("Section1").Controls
.Item("text1").DataField = rs_rpt("Name").Name
.Item("text2").DataField = rs_rpt("Surname").Name
.Item("text3").DataField = rs_rpt("FatherName").Name
.Item("text4").DataField = rs_rpt("Address").Name
.Item("text5").DataField = rs_rpt("Policestation").Name
.Item("text6").DataField = rs_rpt("District").Name
.Item("text7").DataField = rs_rpt("State").Name
.Item("text8").DataField = rs_rpt("Occupation").Name
.Item("text9").DataField = rs_rpt("Identification").Name
.Item("text10").DataField = rs_rpt("DateofBirth").Name
.Item("text11").DataField = rs_rpt("DateofJoining").Name
End With
Set DataReport1.DataSource = rs_rpt
DataReport1.Show
End Sub