OpenRecordset ("Table") or SQL statement 
Author Message
 OpenRecordset ("Table") or SQL statement

Hi!
Can somebody tell me why FindFirst works when I use SQL statement like

    Dbs.OpenRecordset ("SELECT * FROM mytable")

and doesn't work if I write

   Dbs.OpenRecordset ("mytable")?

What is the difference?  I would appreciate the clarification.
Thanks!
--
Gene



Fri, 18 May 2001 03:00:00 GMT  
 OpenRecordset ("Table") or SQL statement
The Find methods (FindFirst, FindNext, FindPrevious, and FindLast) only work
with dynaset-type and snapshot-type recordsets, not with table-type
recordsets. Since the DBEngine found a table called 'mytable', it defaults
to a table-type. You can force a different type with the code:
   Dbs.OpenRecordset ("mytable", dbOpenDynaset)
or
   Dbs.OpenRecordset ("mytable", dbOpenSnapshot)

If you still open it using
   Dbs.OpenRecordset ("mytable", [dbOpenTable])
you could use the Seek method, which is faster than the Find methods because
Seek uses indexes of the table.

Jeff Smith
JCom Computer Training

Quote:

>Hi!
>Can somebody tell me why FindFirst works when I use SQL statement like

>    Dbs.OpenRecordset ("SELECT * FROM mytable")

>and doesn't work if I write

>   Dbs.OpenRecordset ("mytable")?

>What is the difference?  I would appreciate the clarification.
>Thanks!
>--
>Gene



Sat, 19 May 2001 03:00:00 GMT  
 OpenRecordset ("Table") or SQL statement
By default, the first OpenRecordset creates a Dynaset-type recordset, and the
second creates a Table-Type recordset.  If you look in HELP for FindFirst, you
will find it says that FindFirst can only be used with Dynaset-Type and
Snapshot-Type recordsets.  You can force the second syntax to create a
Dynaset-type recordset by using:
                Dbs.OpenRecordset("mytable", dbOpenDynaset)
Then you can use the FindFirst method on the result.

Lee Weiner
weiner AT fuse DOT net



Quote:
>Hi!
>Can somebody tell me why FindFirst works when I use SQL statement like

>    Dbs.OpenRecordset ("SELECT * FROM mytable")

>and doesn't work if I write

>   Dbs.OpenRecordset ("mytable")?

>What is the difference?  I would appreciate the clarification.
>Thanks!



Sat, 19 May 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. OpenRecordset("Table",dbOpenTable) locks record changes?

2. "OpenRecordset" using sql

3. Table driven "If then" statements

4. SQL-Statement "Like"?

5. SQL: include "'" within the statement

6. SQL "IN" Statement

7. Need help w/ SQL "FROM" statement

8. OpenRecordSet "Type Mismatch"

9. Openrecordset "Type mismatch"

10. Openrecordset "Select into" causes invalid operation

11. *"*-.,._,.-*"* I"LL TRADE VISUAL C++ FOR VBASIC *"*-.,_,.-*"*

12. "IF" Statement for form

 

 
Powered by phpBB® Forum Software