OK, I decided to implement it the way described above. I got it partially working but got stuck in some place...
I have the ListView working fine, then upon selecting the record another screen opens up showing the details and buttons to the Child Tables, i.e. Symptoms, BodySystems, BodyParts etc...
When I select BodySystems everything works fine and I'm able to list Child Records, however every other Child Activity fails. For example when I click on BodySystems the ListView shows blank.
Here is the code... which calls the DiseaseFormView (Activity) from the ListView
Sub ListView1_ItemClick (Position As Int, Value As Object)
selectedDiseaseID = Value
CallSubDelayed2(DiseaseFormView, "ShowForm", selectedDiseaseID)
End Sub
then the code (image: des2.png) to open child activity
Sub btnSymptoms_Click
CallSubDelayed2(DiseaseSymptomsList, "ShowForm", selectedDiseaseID)
End Sub
this works
then little below a code to call another Child Activity
Sub btnBodySys_Click
CallSubDelayed2(DiseaseBodySystems, "ShowForm", selectedDiseaseID)
End Sub
this calls the
DiseaseBodySystems which doesn't work....
the code for the
DiseaseSymptomsList activity that works (although it needs some adjustment)
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim SQL1 As SQL
Dim QueryString2 As String
Dim lblName As Label
Dim lblSubname As Label
Dim ListView1 As ListView
Dim Cur As Cursor
Dim SelectedRecordID As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
SQL1.Initialize(Main.dbFileDir, Main.dbFileName, True)
Activity.LoadLayout("dSymptomsList")
End Sub
Sub ShowForm(RecordID As String)
Activity.Title = "Disease - Symptoms"
SelectedRecordID = SQL1.ExecQuerySingleResult("SELECT DiseaseID FROM dDISEASES WHERE DiseaseID="&RecordID)
lblName.Text = SQL1.ExecQuerySingleResult("SELECT ComonName FROM dDISEASES WHERE DiseaseID="&RecordID)
lblSubname.Text = SQL1.ExecQuerySingleResult("SELECT ComonSubname FROM dDISEASES WHERE DiseaseID="&RecordID)
ListViewInit
FillListView
End Sub
Sub FillListView
ListView1.Clear
Cur = SQL1.ExecQuery(QueryString2)
For i = 0 To Cur.RowCount - 1
Cur.Position = i
ListView1.AddSingleLine(Cur.GetString("Symptom"))
Next
' cur.Close
End Sub
then here is the code for the one that does not
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim SQL1 As SQL
Dim lblName As Label
Dim lblSubname As Label
Dim ListView1 As ListView
Dim Cur2 As Cursor
Dim lblID As Label
Dim QueryString2 As String
Dim SelectedRecordID As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
SQL1.Initialize(Main.dbFileDir, Main.dbFileName, True)
Activity.LoadLayout("dBodySysList")
End Sub
Sub ShowForm(RecordID As String)
Activity.Title = "Disease - Body Systems Affected"
lblID.Text = RecordID
SelectedRecordID = SQL1.ExecQuerySingleResult("SELECT DiseaseID FROM dDISEASES WHERE DiseaseID="&RecordID)
lblName.Text = SQL1.ExecQuerySingleResult("SELECT ComonName FROM dDISEASES WHERE DiseaseID="&RecordID)
lblSubname.Text = SQL1.ExecQuerySingleResult("SELECT ComonSubname FROM dDISEASES WHERE DiseaseID="&RecordID)
ListViewInit
FillListView
End Sub
Sub FillListView
ListView1.Clear
QueryString2 = "SELECT ID, DiseaseId, BodySystem FROM dBODYSYSATK WHERE DiseaseID="&SelectedRecordID
Cur2 = SQL1.ExecQuery(QueryString2)
For i = 0 To Cur2.RowCount - 1
Cur2.Position = i
ListView1.AddSingleLine(Cur2.GetString("BodySystem"))
Next
' cur.Close
End Sub
Similar code for other activities does not work as well, so only the first is working.
I noticed the ID columns in some of the child tables do not start from 1 (simply some records were deleted manually while testing), but this should not affect it.
Any ideas appreciated.
Arthur