Avatar billede nyholm Novice
15. december 2007 - 18:38 Der er 7 kommentarer og
1 løsning

Is Find file open?

When I close my db I want to check if the Find File dialog is open and if so it should close it before the db closes.
It has happend that I, by mistake has opend 2 dialogs and has not been aware of that one is still open when I closed th db, with the result that Access stops working.
A good pice of kode, anyone?
Avatar billede terry Ekspert
16. december 2007 - 12:44 #1
I think the easiest method is to make the form which you use to open the dialog box modal, so that you cant close the datbase until you first close the form.

Have a Public variable in the form for example

Public dialogOpen as Boolean

In the form open event set this to False

In the code which opens the dialog you need to set the variable to
True just before you open and False just after you close.

In the form unload you have some code similar to this

if DialogOpen Then

    MsgBox "Close the dialog ...."
    Cancel = True

End If


There is maybe some code which you can use to automatically close dialog but I havent found it yet
Avatar billede nyholm Novice
16. december 2007 - 13:22 #2
Hi Terry!
How do I get it to work?
I have "Public dialogOpen as Bolean" as a declaration.
I have "Set dialogOpen = False" in the open event.
I get a compile error that says that it needs an Object.
What's wrong?
Avatar billede terry Ekspert
16. december 2007 - 13:30 #3
dont use set, just

dialgopen = False
Avatar billede nyholm Novice
16. december 2007 - 13:56 #4
Yes, it works. Thank You
Avatar billede nyholm Novice
16. december 2007 - 14:11 #5
In the event 2 dialogs are open when I close the form, it does'nt react when the one dialog is closed and the other is still open.
Avatar billede terry Ekspert
16. december 2007 - 14:30 #6
why do you allow more than one to be opened? You could disable the button which you use to open the dialog and then enable again at the same time you set dialogOpen. And actually if you did that you could use the status of the button instead of dialogOpen varaible.
Avatar billede nyholm Novice
16. december 2007 - 14:36 #7
That is correct. Thanks again.
Avatar billede terry Ekspert
16. december 2007 - 14:42 #8
your welcome, thank you too.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester