Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 - Find (ADO) Syntax 5

Status
Not open for further replies.

sanders720

Programmer
Aug 2, 2001
421
US
Going a little crazy here. I am trying to use Find with ADO to jump to an Access database record based on selection criteria in my combo box. Bel,ow are five attempts at using the command, and there must be some syntactical issue here. FYI, the field sCustCode is textual in the database.


#1 ' .Find .Fields("sCustCode") = cboCustCode.Text
#2 ' .Find "SELECT sCustCode FROM tblCustomer WHERE sCustCode = '" & cboCustCode.Text & "' "
#3 ' .Find "[sCustCode] = " & cboCustCode.Text
#4 ' .Find (.Fields("[sCustCode]") = cboCustCode.Text)
#5 ' .Find (.Fields("sCustCode") = cboCustCode.Text)

Thanks in advance for the help.
 
.Find is used to locate rows in a recordset that already is opened with a 'SELECT statement'.
Try
Rst.find "sCustCode='" & cboCustCode.Text & "'" Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
The syntax for an ADO recordset’s find method is. . . .

rs.Find "ColumnNameInRecordset = 'Data To Find'"

Where (ColumnNameInRecordset) is the name of the field / column in the recordset and (Data To Find) is the target data you’re looking for and is wrapped in ‘ tick marks

This sample of Find use's a recordset populated with data from an Access Database.
 
sanders720:

.Find "CustCode = '" & cboCustCode.Text & "'"

Where CustCode is the name of the field [/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Sorry sunaj, RonVaught . Somehow I overlooked your answers.... [/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
I have a problem with my VB, it come out this error:

Run tim error -2147217879(80040e29)
Rowset does not support scrolling backward

what does this mean?
 
Vincentan, you have that error because you defined the recordset's cursortype to "adOpenForwardOnly". change it to "adOpenStatic"
 
For DAO there will be a function call

.match and . notmatch ?? but in ADODB can we still use this function or is any other of using this ?

Please advice any expertise here?
 
In ADO, after using the Find method, check the .EOF property.
If it is True, then there were no records found between the record where the search began and the end of the recordset.

You could easily create your own NoMatch property and/or Find Method with a return value, easiest by creating a recordset Clone and doing the record search there, and using the Bookmark property to set the main recordset Bookmark to the RS Clone's Bookmark, if a record was found.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top