TechLad
asked on
adodc1.recordset.find
hi,
How do you use the adodc1.recordset.find or something like that in VB6 to search the table, for the users input on a textbox ?
How do you use the adodc1.recordset.find or something like that in VB6 to search the table, for the users input on a textbox ?
ASKER
Sorry I dont get this, I'm thick. Whats all the Yourconnection ?
dim CN as adodb.connection
the YourConnection would be CN
the Object ADODC as you have shown has a recordset that you use the find method...
you must move to the first row of the recordset...
ADODC.Recordset.MoveFirst
ADODC.Recordset.Find "FieldName = '" & trim(txtField.Text) & "' "
the YourConnection would be CN
the Object ADODC as you have shown has a recordset that you use the find method...
you must move to the first row of the recordset...
ADODC.Recordset.MoveFirst
ADODC.Recordset.Find "FieldName = '" & trim(txtField.Text) & "' "
ASKER
Cool that worked, one last thing is there a way of displaying a message if theres no record found ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.Open "Your SQL", YourConnection
rst.Find, "SomeField= SomeValue"
However, you might be better off with a filtered recordset:
rst.Open "SELECT * FROM SomeTable WHERE SomeField=SomeValue", YourConnection
To reflect user input:
rst.Open "SELECT * FROM SomeTable WHERE SomeField=" & Me.YourTextbox, YourConnection
If "SomeField" is a Text value:
rst.Open "SELECT * FROM SomeTable WHERE SomeField='" & Me.YourTextbox & "'", YourConnection