Hellow everyone

Could somebody show me some code Searching/Finding record on a Database Access.
when i type in textbox1 the last name and first name all the record will be displayed on datagrid and when no record is found it will generate message that the record dont exist.

Plss i need some help with this im a newbie here.... Thanks in advance

1. You need to frame the query dynamically at run time by taking parameter from the input.
2. Open the record set using the sql.
3. Populate the grid from the recordset.
4. If record count is 0 display the alternate message.

try these codes

adodc1.connectionstring="location of database"

adodc1.recordsource="select * from table where Name ='" & textbox1.text & "'"


if adodc1.recordset.recordcount = 0 then
Msgbox"Record not found",vbinformation
set datagrid1.datasource=adodc1
end if

this is my code but it dint work tell what is wrong with this

Option Explicit

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

Private Sub Form_Load()

Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Database1.mdb;Persist Security Info=False"
End Sub

Private Sub Text1_Change()
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "Select Last_Name,First_Name From Table1 Where Last_Name = '" & Text1.Text & "'", cn, adOpenStatic, adLockOptimistic

If rs.RecordCount = 0 Then

MsgBox "............", vbInformation


Set DataGrid1.DataSource = cn

End If

Set DataGrid1.DataSource = rs

yeah i do that but it wont display the data i get blank output. and no message when i input a data that doesn't exit.

try to debug the code.

use like in place of = in the where clause

move the following lines to form_load event
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient

close the recordset after populating the drid

i had it working now but i use command button