Hi Connie,
'~~~~~~~~~~~~~~~~~~~~~~~
Dim db as dao.database _
, rs as dao.recordset
Set db = DBEngine(0)(0)
Set rs = db.OpenRecordset( ...
'
' statements
'
Proc_Exit:
on error resume next
if Not rs is Nothing then
rs.close
set rs = Nothing
end if
set db = nothing
Exit sub ' or function, whichever is applicable
Proc_Err:
MsgBox Err.Description, , _
"ERROR " & Err.Number _
& " ProcedureName : " & Me.Name
Resume Proc_Exit
'if you want to single-step code to find error, CTRL-Break at MsgBox
'then set this to be the next statement
Resume
'~~~~~~~~~~~~~~~~~~~~~~~
Warm Regards,
Crystal
Learn Access on YouTube
http://www.YouTube.com/LearnAccessByCrystal
*
(: have an awesome day :)
*
________________________________
From: acravenrohm <yahoo@craven.de>
To: MS_Access_Professionals@yahoogroups.com
Sent: Friday, August 10, 2012 4:05 PM
Subject: Re: [MS_AccessPros] "too many databases" and DBEngine(0)(0)
A quick, parallel question, to John and/or Crystal. Does "CodeDb" work the same way as "CurrentDb" by creating a copy?
(Microsoft's Help still, since Access 2000, says one should use CurrentDB rather than DBEngine(0)(0) ... "best practices", "best" for who? And why?)
--- In MS_Access_Professionals@yahoogroups.com, John Viescas <JohnV@...> wrote:
>
> Connie-
>
> CurrentDb returns a *copy* of the current database with all the collections
> refreshed. DBEngine(0)(0) references the current database without making a
> copy. The latter is a skosh faster, but may not reflect the latest changes to
> the collections (for example, if other code has added or deleted an object). If
> you Set db = CurrentDb, you should always Set db = Nothing before executing to
> release the copy.
>
> John Viescas, author
> Microsoft Office Access 2010 Inside Out
> Microsoft Office Access 2007 Inside Out
> Building Microsoft Access Applications
> Microsoft Office Access 2003 Inside Out
> SQL Queries for Mere Mortals
> http://www.viescas.com/
> (Paris, France)
>
>
>
>
> -----Original Message-----
> From: MS_Access_Professionals@yahoogroups.com
> [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of mrsgoudge
> Sent: Friday, August 10, 2012 9:57 PM
> To: MS_Access_Professionals@yahoogroups.com
> Subject: [MS_AccessPros] "too many databases" and DBEngine(0)(0)
>
> Crystal and all:
>
> I just saw this from Crystal:
>
> my experience has shown using DBEngine(0)(0) instead of CurrentDb when
> possible is a good idea to reduce the "too many databases open" error.
>
> How does one use DBEngine(0)(0)? I currently have two types of currentdb in my
> code and I'd like to change them:
>
> 1. Dim db As DAO.Database then "Set db = Currentdb)
>
> 2. CurrentDb.Execute "DELETE
>
> Thanks!
> Connie
>
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
------------------------------------
Yahoo! Groups Links
[Non-text portions of this message have been removed]
Jumat, 10 Agustus 2012
Re: [MS_AccessPros] "too many databases" and DBEngine(0)(0)
__._,_.___
.
__,_._,___
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar