Re: SELECT Queries. A straight answer.



On Dec 23, 4:47 pm, "David W. Fenton" <XXXuse...@xxxxxxxxxxxxxxxxxxx>
wrote:

I don't like using CurrentDB directly because certain things go out
of scope immediately. The database reference itself doesn't, as it's
just used to open the recordset, but I've had issues with it in
other cases.

Of course, I use a cached database variable wrapped in a function,
rather than repeatedly using CurrentDB.

Perhaps you could try CurrentProject.Connection.Execute. This avoids
things going out of scope (actually CurrentDB creates a new instance
of the current database each time it is called which is why the
properties, objects etc of one CurrentDB are not the properties,
objects of another CurrebtDB, that is [CurrentDB is CurrentDB] must be
always false. It's as if every time we wrote "Lyle Fairfield" another
Lyle Fairfield (not necessarily an exact clone, for if there were
changes in the real Lyle Fairfield during the time of the creations
then we would see different shadows on the wall.)) And of course,
CurrentProject.Connection.Execute is very simple, doesn't have to be
released (closed or set to nothing), and the returned Recordset
provides some capabilities that Jet's Recordset does not. GetString
and Save (to a local text or xml file) are two that come to mind right
away.


.



Relevant Pages

  • Re: Connection types and speeds
    ... All recordset inserts seen to consequently have 0ms execution time, ... actually written to the database while the code has regained control ... Every time you use CurrentDb, ... RecordsetClone of a form) when a transaction was rolled back, ...
    (microsoft.public.access.queries)
  • RE: Recordset Tutorial
    ... when i enter CurrentDb in my AfterUpdate event property i find that when i ... > A recordset can be either a table or a query - simple as that. ... > reference to a database object: ... > Dim dbf As Database ...
    (microsoft.public.access.formscoding)
  • Re: Do I need to set object = nothing?
    ... and to dereference your objects. ... variables to Nothing if they had already been set to CurrentDb(). ... and in the function set a Database type ... 'Do I need to close the recordset? ...
    (comp.databases.ms-access)
  • Re: It record exists then...
    ... Dim rs As Recordset, db As Database ... Set db = CurrentDb ...
    (microsoft.public.access.formscoding)
  • Re: How to import certain fields from access database?
    ... I added the code but its not displaying any values in the textboxes. ... The first imports data from a database ... Dim myActiveRecord As Recordset ...
    (microsoft.public.word.mailmerge.fields)

Loading