Option Explicit
Dim connectionado As ADODB.Connection
Dim recordsetado As ADODB.Recordset
Dim num As Integer

Private Sub cmdCanceL_Click()
frmSTUDENT.Enabled = True
frmSTUDENT.Show
Unload Me
End Sub

Private Sub openDbaseConnection()
    connectionado.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\student\My Documents\dbStudentInfo.mdb;Persist Security Info=False"
    connectionado.Open
    
    recordsetado.ActiveConnection = connectionado
    recordsetado.CursorLocation = adUseClient
    recordsetado.CursorType = adOpenStatic
    recordsetado.LockType = adLockOptimistic
    recordsetado.Open "Select * FROM tblStudentInfo"
End Sub

Private Sub cmdExit_Click()
frmSTUDENT.Show
End Sub

Private Sub cmdSearch_Click()

recordsetado.MoveFirst
For num = 0 To recordsetado.RecordCount - 1
If txtsearch.Text = recordsetado!StudentID Then
frmSTUDENT.txtStudentID.Text = recordsetado!StudentID
frmSTUDENT.txtStudentName.Text = recordsetado!StudentName
frmSTUDENT.txtSection.Text = recordsetado!Section
frmSearch.Hide
frmSTUDENT.Show
txtsearch.Text = ""
Else
recordsetado.MoveNext
End If
Next num
If Not num = recordsetado.RecordCount Then
MsgBox "Not Found"
End If
End Sub

Private Sub Form_Load()

    Set connectionado = New ADODB.Connection
    Set recordsetado = New ADODB.Recordset
    num = 0
    Call openDbaseConnection
    
End Sub

So did you actually have a question about this code?

commented: Nice HR here, thanks. +6

what the problem with your code friend?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.