Question : search method in VBA Access

iam coding a search routine that if supplied with a set of symptoms then it will then go ahead and retrieve the disease or the diseases that match the symptoms and output the results to the console.but the program only matches for the first symptom supplied by the user and ignores the rest. i dont know why and can you bail me out guys.



Private Sub search_click()
On Error GoTo Err_search_Click


    Dim mydata
    Dim mysympt
    Dim mymed
    Dim myprev
    Set mydata = CurrentDb.openrecordset("disease")
    Set mysympt = CurrentDb.openrecordset("symptoms")
    Set mymed = CurrentDb.openrecordset("medication")
    Set myprev = CurrentDb.openrecordset("prevention")
    With mydata
    Do While Not mydata.EOF
    match = mysympt.Fields("Sname")
    Text7.SetFocus
    If InStr(Text7.Text, match) Then
     Do While Not mydata.EOF
       If mydata.Fields("dname") = mysympt.Fields("dname") Then
         Do While Not mymed.EOF
          If mymed.Fields("medcode") = mydata.Fields("medcode") Then
          Do While Not myprev.EOF
          If myprev.Fields("dname") = mydata.Fields("dname") Then
           Text20.SetFocus
            Text20.Text = mysympt.Fields("dname")
            Text23.SetFocus
            Text23.Text = mymed.Fields("medtype")
            Text26.SetFocus
            Text26.Text = myprev.Fields("pname")
            Exit Do
            End If
            myprev.MoveNext
            Loop
            Exit Do
            End If
            mymed.MoveNext
            Loop
         Exit Do
         End If
         mydata.MoveNext
         Loop
    Exit Do
    Else
    mysympt.MoveNext
    End If
   Loop
    End With
Exit_search_Click:
    Exit Sub

Err_search_Click:
    MsgBox err.Description
    'Resume Exit_search_Click
   
End Sub

Answer : search method in VBA Access

Per recommendation, points NOT refunded and question closed.

Netminder
CS Moderator
Random Solutions  
 
programming4us programming4us