0
Private Sub Cmbfullname_Click()
Dim SQL As String
Dim FName, SName, LName As String
FName = Mid(Combo14.Text, 1, InStr(1, Combo14.Text, " ", vbTextCompare))
SQL = "SELECT A.ROLLNO,A.FIRST_NAME,A.MIDDLE_NAME,A.LAST_NAME,A.CONTACT,A.CONTACT1,A.CONTACT2,A.ADDRESS,A.GRADE,B.DIV,A.BLOOD_GROUP,C.HOUSE,A.DATE_OF_BIRTH,A.TRANSPORT,A.SNAME,A.MEAL,A.BUSNO,A.RUTNO,D.DNAME,D.DCONT,E.ANM,D.DADD,A.CARD_TYPE,A.CARD_NO FROM STUDENT_RECORD_DATABASE A,DIVISION B,HNM C,DRIVER D,ATTEND E WHERE A.DIVID=B.DIVID AND A.HID=C.HID AND A.DID=D.DID AND A.AID=E.AID AND "
SQL = SQL + "FIRST_NAME='" & FName & "'"
Set RES = CON.Execute(SQL)
If RES.RecordCount > 0 Then
   RES.MoveFirst
        COMBO4.Text = RES!ROLLNO
        Text2.Text = RES!FIRST_NAME
        Text3.Text = RES!MIDDLE_NAME
        Text4.Text = RES!LAST_NAME
        Text5.Text = RES!CONTACT
        Text6.Text = RES!CONTACT1
        Text7.Text = RES!CONTACT2
        Text8.Text = RES!ADDRESS
        Combo1.Text = RES!GRADE
        Combo2.Text = RES!DIV
        Combo3.Text = RES!BLOOD_GROUP
        Combo9.Text = RES!HOUSE
        DTPicker1.Value = RES!DATE_OF_BIRTH
        Combo10.Text = RES!TRANSPORT
        Combo5.Text = RES!SName
        Combo11.Text = RES!MEAL
        Combo6.Text = RES!BUSNO
        Combo12.Text = RES!RUTNO
        Combo7.Text = RES!DNAME
        Text9.Text = RES!DCONT
        Combo8.Text = RES!ANM
        Text10.Text = RES!DADD
        Combo13.Text = RES!CARD_TYPE
        Text11.Text = RES!CARD_NO
    End If
    Exit Sub

Private Sub Cmbfullname_LostFocus()
Dim temp As Variant
temp = Split(Combo14.Text, " ")
If temp(0) <> Empty Then
   Combo14.Text = FIRST_NAME
If UBound(temp) Then
    Text2.Text = temp(0)
Else
If UBound(temp) Then
    Text3.Text = temp(1)
Else
If UBound(temp) Then
    Text4.Text = temp(2)
End If
End If
End If
End If
End Sub

Private Sub Text2_LostFocus()  //This code is repeated for text3 and text4 also
Dim SQL As String
Combo14.Clear
Dim STR() As String
STR = Split(Text2.Text, " ")
If STR(0) <> Empty Then
SQL = "SELECT * FROM STUDENT_RECORD_DATABASE WHERE FIRST_NAME='" & STR(0) & "'"
Set RES = CON.Execute(SQL)
 If RES.RecordCount > 0 Then
    RES.MoveFirst
        For I = 0 To RES.RecordCount - 1
Combo14.AddItem RES.Fields("FIRST_NAME").Value & "" & RES.Fields("MIDDLE_NAME").Value & "" & RES.Fields("LAST_NAME").Value
    RES.MoveNext
    Next
End If
Combo14.Text = STR(0)
End If
End Sub

特にこのコードは、text2にfirst_nameを入力したレコードのフルネームを表示しますが、そのうちの1つを選択すると、最初のレコードの情報のみが表示され、他の選択したレコードの情報は表示されません。同じ操作を3つのテキストボックスすべてを使用して実行します。text4は正しい操作を実行しますが、text2、text3はそうではありません。ありがとう

4

0 に答える 0