Ans:
Dim con As New ADODB.Connection
Dim stdrs As New ADODB. Recordset
Private Sub Command1_Click()
If stdrs.State = adStateOpen Then
stdrs.Close
End If
stdrs.Open "select * from studtable where date_admission >= #" & DTPicker1.Value & "# and date_admission <= #" & DTPicker2.Value & "#", con, adOpenDynamic, adLockBatchOptimistic
If (stdrs.BOF = True And stdrs.EOF = True) Then
MsgBox "Record Not Found........"
Else
Set DataReport1.DataSource = stdrs
DataReport1.Sections("Section1") .Controls (1) .DataField = stdrs.Fields(0) .Name
DataReport1.Sections("Section1") .Controls (2) .DataField = stdrs.Fields(1) .Name
DataReport1.Sections("Section1") .Controls (3) .DataField = stdrs.Fields(2) .Name
DataReport1.Sections("Section1") .Controls (4) .DataField = stdrs.Fields(3) .Name
'DataReport1.Sections("Section1") .Controls (5) .DataField = stdrs.Fields(4) .Name
'DataReport1.Sections("Section1") .Controls (4) .Caption = DTPicker2.Value
DataReport1.Show
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
If con. State = adStateOpen Then
con.Close
End If
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E: \ASSINGMENT\bloodreport.mdb; Persist Security Info=False"
If stdrs.State = adStateOpen Then
stdrs.Close
End If
stdrs.Open "select * from studtable", con, adOpenDynamic, adLockBatchOptimistic
DTPicker1.Value = Now()
DTPicker2.Value = Now()
End Sub
No comments:
Post a Comment