473,385 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Multiple Instance of a form limite

Hello

I have a program where the user can open as many instances of a form as the
user wants.

The only limit to how many instances can be opened is determined by the
limit of the computer itself (the amount of RAM - I think). When enough
instances of this form are opened and the limit of the computer is reached
the program crashes and the user has to CTRL^ALT^DELETE and restart the
program.

Is there a way to detect when the computer is approaching its limit so that
I can prevent other instances of the form from being opened?

Also can anyone point me to some reading material on how to minimize the
amount of RAM used by MSACCESS MDE objects?

Thanks

G.Gerard
Jan 18 '06 #1
4 3251
G,
I dont know about your second question, but I had to do the opposite of
the first to keep a user from opening two instances of a database. The
solution should work for you with modification. It's a little on the
hacky side, but hey. :) For forms, EnumChildWindows might work better
for you.
Have fun

Declare Function GetWindowText Lib "user32" Alias _
"GetWindowTextA" _
(ByVal hWnd As Long, _
ByVal lpString As String, _
ByVal cch As Long) As Long

Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As
Long, ByVal lParam As Long) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd
As Long) As Long

Private byDatabasesOpen As Byte 'The number of instances of
this db open on this machine
Private strAppTitle As String 'The title of this
DB
Private hOtherOpenApp As Long 'handle of the other open
db if there is one

Public Function TestForInstances() As Boolean
'************************************************* ************************
' Author Daniel Tweddell
' Date 12/05/02
' Revision
'
' Tests to see if other instances of this database are already open.
If so
' we switch to the other and close this one.
' returns true if there is another instance
'************************************************* ************************
If Not bShowDebug Then On Error GoTo Err_Function
byDatabasesOpen = 0
Dim strName As String * 255
GetWindowText Application.hWndAccessApp, strName, 255 'get this
dbs name
strAppTitle = Trim(strName)
EnumWindows AddressOf WndEnumProc, 0
If byDatabasesOpen Then 'will
register as true if > 0
SetForegroundWindow hOtherOpenApp 'focus on
the open db
TestForInstances = True
End If
Exit Function
Err_Function:
errHandler Err.Number, Err.Description, "TestForInstances()",
bSilent
End Function

Public Function WndEnumProc(ByVal hWnd As Long, ByVal lParam As Long)
As Long
'************************************************* ************************
' Author Daniel Tweddell
' Date 12/05/02
' Revision
'
' callback for the EnumWindows api. Tests the existing windows against
' this one and returns a handle and a count of same named dbs
'************************************************* ************************
If Not bShowDebug Then On Error GoTo Err_Function
Const iSuccess As Integer = 1
Dim strName As String * 255
Dim lSuccess As Long
lSuccess = GetWindowText(hWnd, strName, 255) 'get the name
of the window
If lSuccess <> 0 Then 'see if got
anything
If strAppTitle = Trim(strName) Then 'test it
against our window's name
If hWnd <> Application.hWndAccessApp Then 'make sure it's
not our app
byDatabasesOpen = byDatabasesOpen + 1 'count
hOtherOpenApp = hWnd 'get the other
app's handle
End If
End If
End If
WndEnumProc = iSuccess
Exit Function
Err_Function:
errHandler Err.Number, Err.Description, "WndEnumProc()"
End Function

Jan 18 '06 #2
On Wed, 18 Jan 2006 01:10:05 GMT, "GGerard" <gg*****@nbnet.nb.ca>
wrote:

How many forms would you like to open? You have a front-end MDE +
back-end MDB? What version of Access? What OS?

With the way modern operating systems have near-limitless memory
available (if needed in a swap file), I think it's impossible to
calculate if you can add one more without crashing.
Rather I would look at the nature of your code. For example I think
you would easily be able to open a few dozen instances of any form in
the Northwind sample application. Perhaps something in your code is
contributing to the crash.

I just wrote some code to open the Orders form in Northwind multiple
times. Access 2003 on WinXP. After 54 instances I got a "Reserved
Error". That's plenty of forms for me...

-Tom.

Hello

I have a program where the user can open as many instances of a form as the
user wants.

The only limit to how many instances can be opened is determined by the
limit of the computer itself (the amount of RAM - I think). When enough
instances of this form are opened and the limit of the computer is reached
the program crashes and the user has to CTRL^ALT^DELETE and restart the
program.

Is there a way to detect when the computer is approaching its limit so that
I can prevent other instances of the form from being opened?

Also can anyone point me to some reading material on how to minimize the
amount of RAM used by MSACCESS MDE objects?

Thanks

G.Gerard


Jan 18 '06 #3
"Pachydermitis" <pr*******@gmail.com> wrote in
news:11**********************@g44g2000cwa.googlegr oups.com:
I dont know about your second question, but I had to do the
opposite of the first to keep a user from opening two instances of
a database.


That makes no sense to me. It's impossible without VBA code to
specifically implement it for a user to open multiple instances of a
form. Impossible. So, you don't have to do *anything* to prevent it
except to *not implement it in the first place*.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Jan 18 '06 #4
On Wed, 18 Jan 2006 07:59:19 -0600, "David W. Fenton"
<XX*******@dfenton.com.invalid> wrote:

The writer was referring to two instances of the same *database*,
whereas you are referring to two instances of the same form.

-Tom.

"Pachydermitis" <pr*******@gmail.com> wrote in
news:11**********************@g44g2000cwa.googleg roups.com:
I dont know about your second question, but I had to do the
opposite of the first to keep a user from opening two instances of
a database.


That makes no sense to me. It's impossible without VBA code to
specifically implement it for a user to open multiple instances of a
form. Impossible. So, you don't have to do *anything* to prevent it
except to *not implement it in the first place*.


Jan 19 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: kovac | last post by:
Hi NG With the Directory class of Vb. NET I can accessed Active Directory without restriction. If I make a query for the properties of a container (for example, MEMBERS), I get back only 1000...
12
by: (Pete Cresswell) | last post by:
I know I can open many instances of a given form, but I've never done it. Now I'm analyzing an application where that seems like just the ticket: Many investment funds, *lots* of data points for...
1
by: Albano Alves | last post by:
Boas! Estou desenvolver um gestor documental para funcionar numa intranet. Uma das acções é o upload de ficheiros para o servidor. Existe alguma forma de ilimitar o tamanho dos ficheiros no...
7
by: Siv | last post by:
Hi, I have an MDI application that uses a generic "ShowPage" routine in a module that is called when I want to display a child form. The basic idea is that in the module I have declared each form...
4
by: Rich | last post by:
Hello, my app opens a 2nd form (form2) by clicking a button on the first form (form1). I do not want to open form2 in modal form, but I only want one instance of form2 open. So if someone...
6
by: VirtualDev | last post by:
i want to know how to limite the use of CPU by threads using C++. can you help me please?
6
by: Bob Alston | last post by:
Looking for someone with experience building apps with multiple instances of forms open. I am building an app for a nonprofit organizations case workers. They provide services to the elderly. ...
5
by: Neil | last post by:
"lyle" <lyle.fairfield@gmail.comwrote in message news:48c3dde7-07bd-48b8-91c3-e157b703f92b@f3g2000hsg.googlegroups.com... Question for you. I'm doing something similar, only, instead of opening...
2
by: shahalashamo | last post by:
in order to upload image to database,i put a fileUpload control in the InsertItemTemplate of the formView,the code as follows: <asp:FileUpload ID="FileUploadKeyImage"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.