I have developd hospital managment softwere. I use access as databse. I use datareport to print data. I have one field name "Investigation" which contains .textRTF data from richtextbox. My data are saved and displayed properly in richtextbox. I have problem when I print sama data with datareport as item.caption=datafield. It prints all coding material and not proper text and table. Please help me to overcome this problem.
below is part of code
below is part of code
Code:
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim qry As String, i As Integer
Dim n As Long
cnn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & "\\192.168.1.120\d\d\Database.accdb"
qry = "SELECT * FROM IPD WHERE [IP No] = '" + Me.TextBox25.Text + "'"
rst.Open qry, cnn, adOpenKeyset, adLockOptimistic
With DataReport3
Set .DataSource = rst
With .Sections("Section1").Controls
.Item("Name").Caption = "Patient Name: " & rst.Fields("Name").Value
.Item("RegNo").Caption = "Reg No.: " & rst.Fields("Reg No").Value
.Item("Age").Caption = "Age/Sex: " & rst.Fields("Age").Value & "/" & rst.Fields("Sex").Value
.Item("DOA").Caption = "Date of admission: " & Format(rst.Fields("Admitdate").Value, "dd/mm/yyyy")
.Item("IPDNo").Caption = "IPD No.: " & rst.Fields("Ip No").Value
.Item("DOD").Caption = "Date of discharge: " & Format(rst.Fields("Dischargedate").Value, "dd/mm/yyyy")
.Item("Diagnosis").Caption = rst.Fields("Diagnosis").Value
.Item("History").Caption = rst.Fields("History").Value
.Item("Examination").Caption = rst.Fields("Examination").Value
.Item("Hospital").Caption = rst.Fields("Hospital course").Value
.Item("Investigation").Caption = rst.Fields("Investigations").Value
'this field contains richtextbox data as .textRTF
.Item("Treatment").Caption = rst.Fields("Treatment").Value
.Item("Advise").Caption = rst.Fields("Advise").Value
.Item("Condition").Caption = rst.Fields("Condition").Value
If rst.Fields("Operation").Value <> "" Then
.Item("Operation").Caption = rst.Fields("Operation").Value
.Item("Line9").Visible = True
.Item("Label10").Visible = True
.Item("Label22").Visible = True
Else
.Item("Operation").Caption = ""
.Item("Line9").Visible = False
.Item("Label10").Visible = False
.Item("Label22").Visible = False
End If
End With
.Show
.WindowState = 0
End With
Exit Sub
ErrorHandler:
MsgBox "Oops, an error has occured." & vbCrLf & vbCrLf & "Error Code : " & Err.Number & " , " & Err.Description, vbCritical, "Error"
Exit Sub
End Sub