Need Help with FindFirst command.

Need Help with FindFirst command.

Post by Mark Firoozf » Tue, 11 Jul 1995 04:00:00

I'm posting this for a friend, please email to him at



I am currently using the VB Version 3.0 Professional Edition to create a
module to open a database through a custom ODBC driver, create a Snapshot
object, and use the FindFirst method to find the first occurrance of a
string within a record.  However, when I attempt to execute the code within
VB, I receive the following error on the line containing the call to the
FindFirst method:

Can't perform operation; it is illegal.

The line that this error occurs on is the last one in the following block
of code:

Dim myDb As Database
Dim mySnap As Snapshot
Dim mySQL As String
Dim Criteria As String

Set myDb = OpenDatabase("", False, True,

mySQL = "SELECT mrc, version, revdate FROM mrc WHERE mrc LIKE
Set mySnap = myDb.CreateSnapshot(mySQL, DATA_SQLPASSTHROUGH)

txtRecCount.Text = mySnap.RecordCount Criteria = "mrc = '7AMG'"
mySnap.FindFirst Criteria

txtRecCount is a text box containing the number of records retrieved from
the database.  I am confused as to why this error is occurring since I
followed very closely the instructions in the VB Data Access Guide for
the Professional Edition.  I am trying to perform this function without
the presence of a data control on the form.  I have tried variations on
the format of the Criteria string, including putting brackets aroung the
field name:

Criteria = "[mrc] = '7AMG'"

I know for a fact that the value for the field exists in the table and
have executed this code successfully without the call to the FindFirst
method.  Any advice I could get on this matter would be greatly appreciated.


1. Problem: Using FindFirst -- Need Help

I am having difficulty using FindFirst to seek a record from a  field
containing an apostrophe eg. O'Sullivan.

Code example:

        mainrec = "O'Sullivan"
        cmd = "Fullname = " + "'" + mainrec + "'"
        RS1.FindFirst cmd

I receive an immediate error #3077 - Syntax error in expression.

Any help would be greatly appreciated.


2. Help! Just a quick queston...

3. Findfirst method ' need help


5. A simple FindFirst command ... I thought

6. TQuery SQL Property

7. Need Help with command line

8. Long Island - Database Administrators (Sybase, Oracle, DB2, Informix) needed now

9. HELP: need to count records using a command

10. Need help with date command

11. Update command help needed.

12. Need help on ADO commands and parameters