Click to See Complete Forum and Search --> : ADO


faatimah
April 20th, 2001, 10:47 AM
HELLO ALL,

i don't know how to explain this...but basically i have databound-textbox controls associated with my ado object that show the current record, now when i search for a specific record i want to update my view to show me the searched criteria, that is the last name and update all the other textboxes to the values corresponding to the lastname. Something like making my ado recordset move to the searched value.

here is what i have but it just renames the name in the lastName field to the searched value.


Private Sub mnuSearch_Click()
Dim pstrLastName As String
Dim sql As String


pstrLastName = InputBox("Enter name", "Find")

If pstrLastName <> "" Then

sql = "SELECT * FROM Employees WHERE LastName = " & Chr(34) & pstrLastName & Chr(34)

data.con.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\CaseStudies\Mscb.mdb;Persist Security Info=False")


data.record.Open sql, data.con

If data.record.EOF = True Then
MsgBox ("there are no records")
Else


txtFields(2).Text = data.record!LastName

End If

data.record.Close
data.con.Close

End If
End Sub

THANK YOU ,
FATIMA

forty7
April 20th, 2001, 12:49 PM
what is this ado object you have? how is it associated with your textboxes? do you ever get data in your textboxes? if so, what code do you use to get the initial data?

thanx/good luck,
adam

thomas_dipu
April 20th, 2001, 01:51 PM
U are already displaying the value of the search to the textbox(2).

Similiarly display the other fields of the recordset to the remaining textboxes, just as u did for LastName. U have already done the filtering. So u should have the required data in ur recordset