yh_loh
01-09-2001, 08:23 PM
How to use the Search or find function to search the data in the Access Database ?
For example I have fields Call "Name and age" I want to search for name and then the age automatically appear in the age field.
Thank
Loh
kingesk
01-10-2001, 07:03 AM
Here is an example of using a search function with a data control from one of my programs.
datClient is the name of my data control
In this example I pass the value I'm looking for to the subSearch function but you could also use an Inputbox. The text box "txtName" is linked to the other value I'm wanting
from the properties window (which in your case could be the age value).
Also make sure your "Name" field is set as the primary key in your table. Hope this helps,
Eric
udtOutputRecord.strClientName = subSearch(udtInputRecord.strID)
Private Function subSearch(anyvalue)
Dim vntClientSearch As Variant
Dim intID As Integer
Dim strPassName As String
vntClientSearch = datClient.Recordset.Bookmark
intID = Val(anyvalue) 'InputBox("Enter the client id", "Find Client")
datClient.Recordset.Index = "PrimaryKey"
datClient.Recordset.Seek "=", intID
If datClient.Recordset.NoMatch Then
'MsgBox "No match found", vbExclamation, "Find Client info"
datClient.Recordset.Bookmark = vntClientSearch
strPassName = "ERROR NO MATCH"
Else
strPassName = txtName
End If
subSearch = strPassName
End Function
Private Sub datClient_Error(DataErr As Integer, response As Integer)
Select Case DataErr
Case 3021, 524
response = vbDataErrContinue
End Select
End Sub
Iouri
01-12-2001, 06:43 AM
Use SQL
dim sSQL as string
sSQL = " select * from yourtable where Name ='" & Text1 & "'"
rs.OPen sSQl,Connection.....
Iouri Boutchkine
iouri@hotsheet.com