473,324 Members | 2,473 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,324 software developers and data experts.

Problem with opening form by timer event

Hi,
In my database (access 2000) everything is done within the main form
("OpenForm"). It has a timer which triggers the code below. It first
closes all reports and forms. Then it reopens the main form. When the
main form is opened, the user is first asked for a password in a pop up
window, which stores all kind of info in public variables. Problem is
that quite often, the loginform makes access hang (a nonresponsive
login form is displayed on the screen, and a lost "MSACCESS.EXE" is
show in the process list). This ONLY happens when the main form is
started by the "IdleTimeDetected" Sub (which resides in a Module).

To be sure that no remnants of processes are present (and to do regular
cleaning up) I thought to use the CompactDatabase command. When you
compact the database from the menu (Options->Compact&repair), the
database is closed, compacted and re-opened (and automatically opens
the main form). This should resolve the above problem. However I cant
find out how to compact the database from within the "IdleTimeDetected"
Sub.

Would this be possible at all?

Thanks

Mike

===============================

Sub IdleTimeDetected(ExpiredMinutes)
Dim frmName As String

frmName = "OpenForm"

objectCount = Application.Reports.Count
For I = 0 To objectCount - 1
DoCmd.Close acReport, Application.Reports(I).Name, acSaveNo
Next

objectCount = Application.Forms.Count
For I = 0 To objectCount - 1
DoCmd.Close acForm, Application.Forms(I).Name, acSaveNo
Next

DoCmd.OpenForm frmName
DoCmd.Maximize

End Sub
=======================================

Apr 22 '06 #1
12 3019
If you have more than one form or report open and you want to close them by
their id-number, loop through the items backwards

for I = objectcount -1 to 0 step -1

When you close the first form the position of the second form shifts from 1
to 0. This means you will not be able to access forms(1), since it has
become forms(0). This may cause your code to hang.

"insomniux" <di*******@bosschaert.org> wrote in message
news:11**********************@z34g2000cwc.googlegr oups.com...
Hi,
In my database (access 2000) everything is done within the main form
("OpenForm"). It has a timer which triggers the code below. It first
closes all reports and forms. Then it reopens the main form. When the
main form is opened, the user is first asked for a password in a pop up
window, which stores all kind of info in public variables. Problem is
that quite often, the loginform makes access hang (a nonresponsive
login form is displayed on the screen, and a lost "MSACCESS.EXE" is
show in the process list). This ONLY happens when the main form is
started by the "IdleTimeDetected" Sub (which resides in a Module).

To be sure that no remnants of processes are present (and to do regular
cleaning up) I thought to use the CompactDatabase command. When you
compact the database from the menu (Options->Compact&repair), the
database is closed, compacted and re-opened (and automatically opens
the main form). This should resolve the above problem. However I cant
find out how to compact the database from within the "IdleTimeDetected"
Sub.

Would this be possible at all?

Thanks

Mike

===============================

Sub IdleTimeDetected(ExpiredMinutes)
Dim frmName As String

frmName = "OpenForm"

objectCount = Application.Reports.Count
For I = 0 To objectCount - 1
DoCmd.Close acReport, Application.Reports(I).Name, acSaveNo
Next

objectCount = Application.Forms.Count
For I = 0 To objectCount - 1
DoCmd.Close acForm, Application.Forms(I).Name, acSaveNo
Next

DoCmd.OpenForm frmName
DoCmd.Maximize

End Sub
=======================================

Apr 22 '06 #2
This sounds reasonable. I'll give it a try.
Thanks
Mike

Apr 22 '06 #3
"insomniux" <di*******@bosschaert.org> wrote in
news:11**********************@z34g2000cwc.googlegr oups.com:
Hi,
In my database (access 2000) everything is done within the
main form ("OpenForm"). It has a timer which triggers the code
below. It first closes all reports and forms. Then it reopens
the main form. When the main form is opened, the user is first
asked for a password in a pop up window, which stores all kind
of info in public variables. Problem is that quite often, the
loginform makes access hang (a nonresponsive login form is
displayed on the screen, and a lost "MSACCESS.EXE" is show in
the process list). This ONLY happens when the main form is
started by the "IdleTimeDetected" Sub (which resides in a
Module).
You have bugs in the IdleTimeSelected Sub. That's what is
causing the system to hang. See my comments in thecode below.

To be sure that no remnants of processes are present (and to
do regular cleaning up) I thought to use the CompactDatabase
command. When you compact the database from the menu
(Options->Compact&repair), the database is closed, compacted
and re-opened (and automatically opens the main form). This
should resolve the above problem. However I cant find out how
to compact the database from within the "IdleTimeDetected"
Sub.

Would this be possible at all?
Until you fix your bug, it would be dangerous.
===============================

Sub IdleTimeDetected(ExpiredMinutes)
Dim frmName As String

frmName = "OpenForm"

objectCount = Application.Reports.Count
For I = 0 To objectCount - 1
DoCmd.Close acReport, Application.Reports(I).Name,
acSaveNo
Next
Watch what is happening in your loop.
I is zero. You close the report 0. Access renumbers all the open
reports by decrementing their index number.
You loop, and close report 1. That report was report 2 before
you closed report 0. And you have left report 0, which was
originally numbered 1, open.

Change to a do loop

Do until application.reports.count = 0
DoCmd.Close acReport, Application.Reports(0).Name, _
acSaveNo
loop
objectCount = Application.Forms.Count
For I = 0 To objectCount - 1
DoCmd.Close acForm, Application.Forms(I).Name, acSaveNo
Next
Do until application.forms.count = 0
DoCmd.Close acReport, Application.forms(0).Name, _
acSaveNo
loop
DoCmd.OpenForm frmName
DoCmd.Maximize

End Sub
=======================================


--
Bob Quintal

PA is y I've altered my email address.
Apr 22 '06 #4
hopefully the solution posted elsewhere in this thread will work for you,
since it's better to eliminate the cause of the error rather than
side-stepping it.

just as an fyi, you can use the following code to compact a database, as

On Error GoTo Compact_Err

Dim str As String
str = "Compact and Repair Database..."

CommandBars("Menu Bar").Controls("Tools").Controls("Database
Utilities").Controls(str).accDoDefaultAction

Compact_End:
Exit Sub

Compact_Err:
MsgBox err.Number & " " & err.Description, "Administrator:
isCompact()"

it will run from a form's module, or you can paste it into a Public Sub in a
standard module and call it from a form module.

hth
"insomniux" <di*******@bosschaert.org> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
This sounds reasonable. I'll give it a try.
Thanks
Mike

Apr 22 '06 #5
> CommandBars("Menu Bar").Controls("Tools").Controls("Database_
Utilities").Controls(str).accDoDefaultAction

Here I've a problem. I'm using a Dutch version of access. I can get all
commands from the menu's, except the first one "Menu Bar".

Application.CommandBars("Menu Bar")_
.Controls("Extra")_
.Controls("Databasehulpprogramma's " )_
.Controls("Database comprimeren en herstellen...").accDoDefaultAction
If I try CommandBars(1), or debug.print commandBars(1).Name, Access
crashes. The next time I open the database I get an error 3159, meaning
that I have to convert to a previous version and back to 2000 to be
able to open the database again.
I guess this should not be normal behaviour. Do I need to load special
references to access these properties?

Apr 23 '06 #6
"insomniux" <di*******@bosschaert.org> wrote in
news:11*********************@j33g2000cwa.googlegro ups.com:
CommandBars("Menu Bar").Controls("Tools").Controls("Database_

Utilities").Controls(str).accDoDefaultAction

Here I've a problem. I'm using a Dutch version of access. I
can get all commands from the menu's, except the first one
"Menu Bar".

Application.CommandBars("Menu Bar")_
.Controls("Extra")_
.Controls("Databasehulpprogramma's " )_
.Controls("Database comprimeren en
herstellen...").accDoDefaultAction
If I try CommandBars(1), or debug.print commandBars(1).Name,
Access
crashes. The next time I open the database I get an error
3159, meaning that I have to convert to a previous version and
back to 2000 to be able to open the database again.
I guess this should not be normal behaviour. Do I need to load
special references to access these properties?

Have you fixed the problems with your code that Roland Roos and
I identified, then tested thoroughly? and tested again?. Your
attempt to compact the database if you have mangled a pointer
with bad code may lead to the corruption you ask about here.

--
Bob Quintal

PA is y I've altered my email address.
Apr 23 '06 #7
well, i don't know. as i recall, i didn't need to load any special
references to use the code. the Dutch version of Access may have different
specifications, i suppose. you should also consider Bob's post re this
issue, and my earlier caution that it's better to fix a problem than to
sidestep it.

hth
"insomniux" <di*******@bosschaert.org> wrote in message
news:11*********************@j33g2000cwa.googlegro ups.com...
CommandBars("Menu Bar").Controls("Tools").Controls("Database_

Utilities").Controls(str).accDoDefaultAction

Here I've a problem. I'm using a Dutch version of access. I can get all
commands from the menu's, except the first one "Menu Bar".

Application.CommandBars("Menu Bar")_
.Controls("Extra")_
.Controls("Databasehulpprogramma's " )_
.Controls("Database comprimeren en herstellen...").accDoDefaultAction
If I try CommandBars(1), or debug.print commandBars(1).Name, Access
crashes. The next time I open the database I get an error 3159, meaning
that I have to convert to a previous version and back to 2000 to be
able to open the database again.
I guess this should not be normal behaviour. Do I need to load special
references to access these properties?

Apr 23 '06 #8
Bob and tina,
I've changed the procedure for closing reports and forms as you
suggested. However, the problem appeared before I introduced this code.
In some earlier posts it was suggested that open forms and reports
could cause this problem. That's why I added this code.
Since I have no other clue to the cause of this behaviour, my final
solution was to try a compact&repair.
Mike

tina wrote:
well, i don't know. as i recall, i didn't need to load any special
references to use the code. the Dutch version of Access may have different
specifications, i suppose. you should also consider Bob's post re this
issue, and my earlier caution that it's better to fix a problem than to
sidestep it.

hth


Apr 24 '06 #9
okay, well, hopefully the solution suggested by Roland and Bob took care of
the initial problem for you. sorry i wasn't able to help you get the
compact/repair code working - it is handy to use, in "normal" situations.
good luck with your project. :)
"insomniux" <di*******@bosschaert.org> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Bob and tina,
I've changed the procedure for closing reports and forms as you
suggested. However, the problem appeared before I introduced this code.
In some earlier posts it was suggested that open forms and reports
could cause this problem. That's why I added this code.
Since I have no other clue to the cause of this behaviour, my final
solution was to try a compact&repair.
Mike

tina wrote:
well, i don't know. as i recall, i didn't need to load any special
references to use the code. the Dutch version of Access may have different specifications, i suppose. you should also consider Bob's post re this
issue, and my earlier caution that it's better to fix a problem than to
sidestep it.

hth

Apr 25 '06 #10
"insomniux" <di*******@bosschaert.org> wrote in
news:11**********************@g10g2000cwb.googlegr oups.com:
Bob and tina,
I've changed the procedure for closing reports and forms as
you suggested. However, the problem appeared before I
introduced this code. In some earlier posts it was suggested
that open forms and reports could cause this problem. That's
why I added this code. Since I have no other clue to the cause
of this behaviour, my final solution was to try a
compact&repair. Mike

Could it be that some other unclosed object is causing your
lockup?.

It has been suggested in this group that sometimes referring to a
checkbox value via an implicit instead of explicit call can cause
similar behaviour:. e.g. me.checkbox then (implicit) vs
me!checkbox.value (explicit)

--
Bob Quintal

PA is y I've altered my email address.
Apr 25 '06 #11
OK,
Thanks for pointing to this issue. I'll look into that as well and
report back the result.
Mike

Apr 25 '06 #12
I've been cleaning the code and made all references to checkboxes
explicit. This did not reduce frequency of crashes.
Later, I found that there was a reference in one of the systemtables to
a form which was removed in a previous release. This was definitely not
correct. I could not remove this record manually. What I had to do to
get rid of the remnants of this form was the following:
1. create a form with the same name (generated an error that the form
already existed, but after that action, the form was shown in the forms
window again).
2. rename the form (it could not be opened or removed, but it could be
renamed).
3. delete the form (after renaming it could be deleted).
After this action, the crashes have not appeared anymore (at least it
has not been reported by the users anymore). Hope this was the culprit
of the problem.
Thanks for your help

May 12 '06 #13

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

Similar topics

3
by: jayderk | last post by:
Hello All, I am running in to a situation where the listbox is not refreshing for me. I am using a timer to cycle every second and call the timer_elapsed() event. in the time_elapsed event...
3
by: Benny | last post by:
Hello Experts, Currently I am working on a windows application using VS.NET 2002 with C#. On one of my form, I have a refresh button which will dispose created controls and re-create them. I...
13
by: Jason Jacob | last post by:
To all, I have a GUI program (use c#), and I have create a Thread for loading some bulk data, I also arrange the GUI program like this: 1) load a form showing "Wait for loading..." etc 2) a...
2
by: Jeff Van Epps | last post by:
We've been unable to get events working going from C# to VJ++. We think that the C# component is being exposed properly as a ConnectionPoint, and the Advise() from the VJ++ side seems to be...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
8
by: Stephen Rice | last post by:
Hi, I have a periodic problem which I am having a real time trying to sort. Background: An MDI VB app with a DB on SQL 2000. I have wrapped all the DB access into an object which spawns a...
2
by: r norman | last post by:
Please excuse the cross-posting. This question was raised in microsoft.public.dotnet.general but hasn't been answered so I am trying where I can. There are two of us who have the same problem...
3
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
I am trying to use the timer to make a login form show after a specified interval. However, if the interval is set to a value greater than 5000 nanosecond, then it does not respond. What could be...
2
by: Johnny Jörgensen | last post by:
I've got a process I want to run in a thread separate from my main application thread, so I've used a backgroundworker component, and in frmMain.Load I invoke the code using...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.