Avatar billede sla03 Nybegynder
11. december 2002 - 11:58 Der er 24 kommentarer og
1 løsning

Access kan ikke lukkes ned korrekt??

Jeg har lavet en Access-applikation til registrering af opgaver som udføres forskellige steder i vores virksomhed. Den består af en backend-databasefil, som indeholder data og front-end applikationer, som brugere gemmer i deres dokumentmappe, og som giver dem adgang til de fælles data.

Problemet som jeg gerne vil have hjælp til at løse er, at brugere kun kan åbne front-end applikationen én gang. Hvis man lukker ned og forsøger at åbne igen sker der noget mystisk:
Der dannes en lock-file, men der vises ingen skærmbilleder.

Herefter er der INGEN mulighed for at starte applikationen igen, med mindre man åbner Windows Job-liste, og afslutter ACCESS.EXE
                     
Jeg håber at nogle kan komme med et løsningsforslag til hvordan men kan lukke Access ordentlig så man ikke bliver nød til at afslutte Acceess via Joblisten.

//Søren Landström
Avatar billede terry Ekspert
11. december 2002 - 12:13 #1
How are you closing Access at the moment? You can place a buttin on the main form using the wizard. Here you can choose to EXIT Access. Although I do not think this is the problem. If you are making any connections in code the make sure they are all closed correcty.
Also if you are automating other Office applications, make sure you clean up after use.
Avatar billede terry Ekspert
11. december 2002 - 12:13 #2
buttin = button
Avatar billede terry Ekspert
11. december 2002 - 13:51 #3
and?
Avatar billede sla03 Nybegynder
11. december 2002 - 14:12 #4
Hi Terry

I’m using the command ” DoCmd.Quit” to close the database. By the way, the front-end and back-end are linked together. I think you are right about not having closed the connection correctly, but how do I do that?

//Søren Landström
Avatar billede terry Ekspert
11. december 2002 - 14:25 #5
Are you just linking the tables from the database window or are you making a connection in code?

If you are just linking the tables through the dB window then docmd.close should be enough.

Otherwise it is BEST to close recordsets and the dB and then set the object to Nothing
EXAMPLE:
rs.close
db.close
set rs = Nothing
set db = Nothing
Avatar billede terry Ekspert
11. december 2002 - 14:27 #6
Søren, you dont need to reject any answers until you are ready to close the question. Then you can either reject or accept the answers given. This saves us having to place an answer again and we can just give a comment, although it doesnt really matter. I think it wil save you some time though!
Avatar billede sla03 Nybegynder
11. december 2002 - 16:02 #7
Hi Terry

Sorry about rejecting the answer!!

To close my program I now use the function:

Function AfslutProgram()
On Error GoTo AfslutProgram_Err
    DoCmd.Close acTable, "adh_opg"
    DoCmd.Close acTable, "adh_opg_del"
    DoCmd.Close acTable, "adh_opg_fas"
    DoCmd.Close acTable, "dri_rap"
    DoCmd.Close acTable, "dri_rap_opg"
    DoCmd.Close acTable, "eks_tur"
    DoCmd.Close acTable, "dis"
    DoCmd.Close acTable, "bru"
    DoCmd.Quit

AfslutProgram_Exit:
    Exit Function

AfslutProgram_Err:
    MsgBox Error$
    Resume AfslutProgram_Exit

End Function

Sometime I can close and sometime I can't close correctly. Can it be because it takes long time to close linked tabel over the local network?
Avatar billede terry Ekspert
11. december 2002 - 16:15 #8
you still dont say HOW you are attaching to the tables!

Access will close any link IF they are just normal linked tables, you do NOT need these
DoCmd.Close acTable, "bru"
Avatar billede sla03 Nybegynder
11. december 2002 - 16:49 #9
I have just linked the tables manually from the database window!!

PS: If I just open the dB and then close it again it's OK. But if I open forms and look / modify data then I have the problem???
Avatar billede terry Ekspert
11. december 2002 - 16:59 #10
drop all lines
DoCmd.Close acTable .....
Avatar billede sla03 Nybegynder
11. december 2002 - 17:01 #11
Then I'm back to were I started :-(
Avatar billede terry Ekspert
11. december 2002 - 17:06 #12
Is it possible for you to send the dB and backend db to me?
eksperten@santhell.dk

The lines
Docmd.close acTable .... should NOT be necessary!
Avatar billede terry Ekspert
11. december 2002 - 19:13 #13
Søren, I dont seem to have any problems although I may not have changed much at all with the alterations you have made so that I can use the program.

If you copy the backend to your local drive do you still have the problems?
Avatar billede sla03 Nybegynder
12. december 2002 - 08:38 #14
One way to provoke an error is to:
1)    Open dB
2)    Push button “Stamdata”
3)    Chose “Fredericia Transport”
4)    Change some data
5)    Exit

It “works” for me every time

Another way:

1) Open…
2) Set dato =”04-12-2002” and kørselsgruppe =”FAT”
3) Push ”Opdater”
4) Double click    ”opgave-nr.” or “tur-nr” to open and change data
5) Exit

This will provoke the error some times. And before I added the close commands it gave error almoste every time.


//SL
Avatar billede sla03 Nybegynder
12. december 2002 - 08:40 #15
On my local drive it seems to be harder to provoke the error, but the first way i described gives me problems every time
Avatar billede terry Ekspert
12. december 2002 - 09:06 #16
I'll try it and get back
Avatar billede terry Ekspert
12. december 2002 - 09:16 #17
OK, I can provoke the problem so I have something to look at now. I think you can be sure though, that it is NOT your network!
Avatar billede terry Ekspert
12. december 2002 - 10:58 #18
well here is your problem! I have NO IDEA, what it is you are trying to do here so I can not make any suggestions as to what you should do instead. If you remove these lines you get no problem! You can see the lines I have commented out.
What I dont understand is that you are passiing the contents of Forms![f_stam_1]![f_stam_bru].Form![team] which is a text value to, which in some cases contains NULL, to a function which is especting an object of some sort. Then your trying to set ctlList which is a control to point at this object (which may be NULL) and then requery it!!!! So I have to ask, what is it your trying to do?

FORM = f_stam_1

Private Static Function OpdaterKombi(feltnavn As Object)
Dim ctlList As Control
   
    'Set ctlList = feltnavn
    'ctlList.Requery
End Function

    'Opdater disponereingsoversigten
'----------------------------------------------------------------------------
Private Sub OpdaterDispo()
On Error GoTo Opdater_Err

        'OpdaterKombi (Forms![f_stam_1]![f_stam_bru].Form![team])
       
   
Opdater_Exit:
    Exit Sub

Opdater_Err:
   
    MsgBox Error$
    Resume Opdater_Exit

End Sub
Avatar billede terry Ekspert
12. december 2002 - 13:19 #19
Søren have you looked at this?
Avatar billede sla03 Nybegynder
12. december 2002 - 13:28 #20
Yes....and you are right :-) I just deleted the code and now I can open "Stamdata" and restart the system without problems.

But I sill have the other problem:

1) Open…
2) Set dato =”04-12-2002” and kørselsgruppe =”FAT”
3) Push ”Opdater”
4) Double click    ”opgave-nr.” or “tur-nr” to open and change data
5) Exit

I will send you a nother set of back and front-end where I'm sure you will se the problem, OK?
Avatar billede terry Ekspert
12. december 2002 - 13:45 #21
søren>It took me over and hour to fincd this problem, and it may take me just as long for the next. I am guessing that you have roughly the same problem here too so it was maybe an idea to try and find it yourself.
Avatar billede terry Ekspert
12. december 2002 - 13:48 #22
You know your program better than I do so you should be able to debug your way through the program. The error will VERY likley be in the form you are setting the date field. Comment out as much as possible, now the error shouldnt occur.  Then start un-commenting until the error occurs and you should now see the problem. It just takes time :o)
Avatar billede sla03 Nybegynder
12. december 2002 - 13:56 #23
Terry> Thanks for the advices. By the way... did you get the 60 points?
Avatar billede terry Ekspert
12. december 2002 - 13:59 #24
no, not yet! You need to accept my answer.
Avatar billede terry Ekspert
12. december 2002 - 14:18 #25
:o)
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