473,785 Members | 2,720 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3292
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, EnumChildWindow s 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 SetForegroundWi ndow 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 TestForInstance s() 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.hWn dAccessApp, strName, 255 'get this
dbs name
strAppTitle = Trim(strName)
EnumWindows AddressOf WndEnumProc, 0
If byDatabasesOpen Then 'will
register as true if > 0
SetForegroundWi ndow hOtherOpenApp 'focus on
the open db
TestForInstance s = True
End If
Exit Function
Err_Function:
errHandler Err.Number, Err.Description , "TestForInstanc es()",
bSilent
End Function

Public Function WndEnumProc(ByV al 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(h Wnd, 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.hWn dAccessApp 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 , "WndEnumPro c()"
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
"Pachydermi tis" <pr*******@gmai l.com> wrote in
news:11******** **************@ g44g2000cwa.goo glegroups.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*******@dfen ton.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*******@gmai l.com> wrote in
news:11******* *************** @g44g2000cwa.go oglegroups.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
1262
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 Records! How can I turn off this Limite? I use the following code: ...
12
3237
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 each fund, and a desire by the users to see several funds presented side-by-side. Is opening, say, five instances of the same form real-world-doable? -- PeteCresswell
1
3007
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 upload.? Quero dar a possibilidade de fazer upload do ficheiro qualquer que seja o tamanho ainda que demore. Albano
7
3114
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 as follows: Friend F0 As frmMain Friend F1 As frmStart Friend F2 As frmSearch Then in my ShowPage routine (which is passed a string "pageToShow" which is the name of the form I wish to open), I first check to see if we already have an instance...
4
3883
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 re-clicks the button on form1 there will not be multiple instances of form2. I created a module level boolean var in form1 and a property in form1 to control the loading of form2, but I am having a problem resetting the value of this boolean var. ...
6
1555
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
2659
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. so far I have built a traditional app, switchboard, forms, etc. Part of this app is to automate the forms they previously prepared manually. After the app was built and works just fine, I find out there are several case managers using MS word...
5
3311
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 the forms all at once, I'm opening them as needed. I have a main form with multiple records; and then I have a pop-up form that the user opens with button. The pop-up form contains one record relating to the current record in the main form (but...
2
1519
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" runat="server" FileBytes='<%# Bind("keyImage") %>' /> and the FormView is bind to a sqlDataSource,part of code in sqlDataSource is <asp:Parameter Name="keyImage" Type="object" /> ,but when i click the "insert" button...
0
10155
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9953
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8978
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3655
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.