I am making a clinic Management. I have to generate a report of test to be conducted for a particular patient. Problem I am facing is, I am able to display the tests name and costs, But i want to display Patient Name and Doctor Name only ONCE!!
i.e.
Code:
Doctor Name Patient Name Test Cost of Test
Doctor1 Patient 1
test1 cost1
test2 cost2
test3 cost3
But it is being displayed as
Code:
Doctor Name Patient Name Test Cost of Test Doctor1 Patient 1 test1 cost1 Doctor1 Patient 1 test2 cost2 Doctor1 Patient 1 test3 cost3
Also I thought of a little cheat way out of this. I thought i'll create a new table of the values required i.e table (doc name, patient name, test name, test cost) in which my first row will have doc name, patient name, null, null and subsequent rows will have null, null, test name(i), test cost(i)
So it is expected that the values are inserted like this
Code:
DNAME PNAME TESTNAME COST D1 p1 - - - - CHEST XRAY 100 - - URINE 250 - - BLOOD 100
Code:
DNAME PNAME TESTNAME COST - - CHEST XRAY 100 D1 p1 - - - - URINE 250 - - BLOOD 100
If the table is created the first time the values get inserted properly,
but if i insert values after deleting all values it goes random...
Here's the code...
Code:
Private Sub cmdGivePresc_Click()
On Error GoTo step1
If txtInfo(7).Text <> "" Then
step2:
Set temp = New ADODB.Recordset
temp.Open "delete from for2mins", Ado, adOpenKeyset, adLockOptimistic
temp.Open "select * from for2mins", Ado, adOpenKeyset, adLockOptimistic
temp.AddNew
temp(0) = doc_name
temp(1) = pat_name
temp(2) = Null
temp(3) = Null
Set Test = New ADODB.Recordset
Test.Open "select tname, cost from test where test_id in (select test_id from test_result where test_result.presc_id in (select presc_id from appt a, doctor d where a.appt_time = '" & appt_time & "' and a.appt_date = '" & appt_date & "' and d.doc_id = " & doc_id & "))", Ado, adOpenKeyset, adLockOptimistic
While Not Test.EOF
temp.AddNew
temp(0) = Null
temp(1) = Null
temp(2) = Test(0)
temp(3) = Test(1)
Test.MoveNext
Wend
temp.Update
DataEnvironment1.Connection1.Open
DataEnvironment1.Command1
DataReport1.Show
Else
MsgBox "Enter Patient ID or Select Appointment Date/Time", vbCritical
End If
Exit Sub
step1:
DataEnvironment1.Connection1.Close
GoTo step2
End Sub


