Listbox Questions

DrMaestro

Registered User.
Local time
Today, 22:30
Joined
Feb 3, 2007
Messages
21
Hi,

I'd like to ask two questions.
I have a simple form which contains an identification number, patient name and patient surname.I also have a combobox to select a search criteria (which can be the ID numberi patşent name and surname) , a search button and a listbox to show the search results. The code for the OnClick property of the button is as follows: (cmbAra is the combobox's name, ProtokolNo is the patient ID, Ad ise patient name, soyad is patient surname, lstArama is the name of the listbox. The listbox has three columns (Patient ID number, name and surname) )

Code:
Private Sub btnAra_Click()

On Error GoTo Err_btnAra_Click
Dim a As Integer
If IsNull(Me!cmbAra) = False Then
    Select Case Me.cmbAra.Value
        Case "Protokol No"
            If IsNull(Me!txtProtokolNo) = False Then
                Me.lstArama.RowSource = "Select HastaID, ProtokolNo, Ad, Soyad from tblHasta where ProtokolNo = '" & Me!txtProtokolNo & "' Order By Soyad"
                Me.lstArama.Requery
            Else
                a = MsgBox("Please type a protocol number", vbOKOnly, "Hata") 
            End If
        Case "Ad"
            If IsNull(Me!txtAd) = False Then
                Me.lstArama.RowSource = "Select HastaID, ProtokolNo, Ad, Soyad from tblHasta where Ad = '" & Me!txtAd & "' Order By Soyad"
                Me.lstArama.Requery
            Else
                a = MsgBox("Please type a name", vbOKOnly, "Hata") 
            End If
        Case "Soyad"
            If IsNull(Me!txtSoyad) = False Then
                Me.lstArama.RowSource = "Select HastaID, ProtokolNo, Ad, Soyad from tblHasta where Soyad = '" & Me!txtSoyad & "' Order By Ad"
                Me.lstArama.Requery
            Else
                a = MsgBox("Please type a surname", vbOKOnly, "Hata") 
            End If
        End Select
Else
    a = MsgBox("Please choose a search criteria", vbOKOnly, "Hata")
End If


Exit_btnAra_Click:
    Exit Sub

Err_btnAra_Click:
    MsgBox Err.Description
    Resume Exit_btnAra_Click
End Sub
The first thing I would like to achieve is to show a message box if no matching record is found. For example, for the ID number I tried the following statement: If IsNull Me.lstArama = True Then MsgBox "No matching protocol number found" But this statement shows the "no matching protocol number found" message even if there are matching results.

The second thing I'd like to achieve is to be able to select a result from the listbox to open a new form containing those results. What I try to do is as follows: A patient arrives. I check to see if he/she is already present in the database. If a record is present, it is shown on the listbox. I doubleclick it and open a new form to enter the details about his/her actual visit.

Thank you very much for your help...
 

Users who are viewing this thread

Back
Top Bottom