... and here is code for IsSubform, which my CloseMe procedure calls:
'~~~~~~~~~~~~~~~~~~~~ IsSubform
Function IsSubform(pForm As Form) As Boolean
Dim mStr As String
On Error Resume Next
mStr = pForm.Parent.Name
If Err.Number > 0 Then
IsSubform = False
Else
IsSubform = True
End If
End Function
'~~~~~~~~~~~~~~~~~~``
I generally have a procedure on every form LOAD event that finds the record specified by OpenArgs if it exists since I use autonumber fields for PKs, so it is always a long integer. this way, I can close a form and come back to the same place :)
Warm Regards,
Crystal
*
(: have an awesome day :)
*
________________________________
From: Crystal <strive4peace2008@yahoo.com>
To: "MS_Access_Professionals@yahoogroups.com" <MS_Access_Professionals@yahoogroups.com>
Sent: Friday, April 6, 2012 8:47 AM
Subject: Re: [MS_AccessPros] Cannot Open Database
also, set the RecordSourceType to --> Snapshot
instead of Dynaset for forms that just show information.
It is a good idea to not have more than one form open at a time that changes the same set of records.
I normally only keep one form open at a time -- my close procedure optionally opens another form, which I generally default to the main menu form
'~~~~~~~~~~~~~~~~~~~~~~~~~~ CloseMe
Function CloseMe(pF As Form _
, Optional booSave As Boolean = False _
, Optional pFormOpen As String = "" _
, Optional pOpenArgLng As Long = -99 _
) As Byte
' Crystal (strive4peace)
' 8-17-08, 12-1 pOpenForm, 12-19 dirty, 4-9-09
'110512 pOpenArgLng
'if pF is a subform then close the parent
'close a form
'example useage: [Event Procedure] of a Close command button
' CloseMe
' CloseMe Me
' close form and save changes
' CloseMe Me, true
' close form and open/switch to another
' CloseMe Me,, "OtherFormname"
'101220
On Error Resume Next
If Len(pF.RecordSource) > 0 Then If pF.Dirty Then _
pF.Dirty = False
On Error GoTo Proc_Err
'110512 - consider subform
'future - test subform on subform
If IsSubform(pF) Then
DoCmd.Close acForm, pF.Parent.Name _
, IIf(booSave, acSaveYes, acSaveNo)
Else
DoCmd.Close acForm, pF.Name _
, IIf(booSave, acSaveYes, acSaveNo)
End If
If pFormOpen <> "" Then
If CurrentProject.AllForms(pFormOpen).IsLoaded Then
Forms(pFormOpen).Visible = True
DoCmd.SelectObject acForm, pFormOpen
Else
If pOpenArgLng = -99 Then
DoCmd.OpenForm pFormOpen
Else
'pass a long integer in OpenArgs
DoCmd.OpenForm pFormOpen, , , , , , pOpenArgLng
End If
End If
End If
Proc_Exit:
Exit Function
Proc_Err:
' MsgBox Err.Number & " " & Err.Description _
' , , "Cannot close right now "
Resume Proc_Exit
Resume
End Function
'~~~~~~~~~~~~~~~~~~~~~~~
Warm Regards,
Crystal
strive4peace2012 AT yahoo DOT com
Microsoft MVP, Access
remote training and programming
www.AccessMVP.com/strive4peace
www.YouTube.com/LearnAccessByCrystal
www.YouTube.com/LearnByCrystal
* (: have an awesome day :) *
________________________________
From: Crystal <strive4peace2008@yahoo.com>
To: "MS_Access_Professionals@yahoogroups.com" <MS_Access_Professionals@yahoogroups.com>
Sent: Friday, April 6, 2012 8:42 AM
Subject: Re: [MS_AccessPros] Cannot Open Database
Hi Art,
find --> CurrentDb
ChangeTo --> DbEngine(0)(0)
this may not be enough. Make sure you release object variables in every procedure.
If you have just split your database, then you may need to weed your indexes and relationships and import objects into a blank database to clean them up.
Warm Regards,
Crystal
*
(: have an awesome day :)
*
________________________________
From: Art <dbalorenzini@yahoo.com>
To: MS_Access_Professionals@yahoogroups.com
Sent: Friday, April 6, 2012 7:45 AM
Subject: [MS_AccessPros] Cannot Open Database
I am getting this strange error:
"Cannot Open Any More Database" after I have multiple forms open. Is this a sign that I am running out of memory or something? This database is in a multi-user environemnt.
Thanks
Art Lorenzini
------------------------------------
Yahoo! Groups Links
[Non-text portions of this message have been removed]
------------------------------------
Yahoo! Groups Links
[Non-text portions of this message have been removed]
------------------------------------
Yahoo! Groups Links
[Non-text portions of this message have been removed]
Jumat, 06 April 2012
Re: [MS_AccessPros] Cannot Open Database
__._,_.___
.
__,_._,___
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar