Avatar billede faroe Nybegynder
22. september 2001 - 14:03 Der er 13 kommentarer og
1 løsning

Vårdan åpner man en database

jeg skal lave et lille program.
når programmet åpner skal dette starte en darabase
fx c:/databasenavn
og so skal lukket efter 5 sek

men vårdan???
Avatar billede terry Ekspert
22. september 2001 - 14:05 #1
What do you mean \"starte en database\" do you want to open the database in Access or just open a specific table?
A bit more info. pleas faroe!
Avatar billede faroe Nybegynder
22. september 2001 - 14:27 #2
Jeg skal åpne den i access

faktes som en genvej
Avatar billede terry Ekspert
22. september 2001 - 14:35 #3
This code starts access and quits again. You need to put a timer somewhere to keep it oppne as ling as you want.

Dim acc as Object

Set acc = CreateObject(\"Access.Application\")
   
acc.OpenCurrentDatabase FilePath:=\"C\\Yourdatabase.mdb\"

acc.Visible = True

\'time up
acc.quit
Avatar billede terry Ekspert
22. september 2001 - 14:36 #4
You also need a refrence to MS Access Object libraray. Set this in th eproject references menu.
Avatar billede terry Ekspert
22. september 2001 - 14:38 #5
\"C:\\Yourdatabase.mdb\"

faroe>why close after only 5 seconds?

Avatar billede faroe Nybegynder
22. september 2001 - 14:43 #6
det er exe programmet som skal lukke efter 5 sek
ikke databaseb
Avatar billede terry Ekspert
22. september 2001 - 14:49 #7
You could try first with reomiving the acc.quit.
If Access closes when the EXE closes, then try this instead.

Make a module and add the following code. Then change the bit where it says \"YourDatabase.mdb\" to the name of the database you want to open. Then change \"C:\\temp\" to the directory of where the database is.
Then make a call to OpendB

Public Declare Function ShellExecute Lib \"shell32.dll\" Alias \"ShellExecuteA\" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Public Const SW_HIDE = 0
Public Const SW_SHOW = 5

Function OpenDb() as integer
Dim result As Integer
       
    result = ShellExecute(0, \"Open\", \"YourDatabase.mdb\", \"\", \"C:\\temp\", SW_SHOW)

   
end function
Avatar billede terry Ekspert
22. september 2001 - 14:50 #8
reomiving = removing

I have not trued the ShellExecut from VB but I know it works in Access. It should also in VB!
Avatar billede faroe Nybegynder
22. september 2001 - 15:08 #9
exe programmet skal starte databaseb og so skal dette lukke efter 5 sek, mens databasen kærer videre, jeg lukker databaseb normalt.

skal tette ikke en timer på formen i exe programmet?
Avatar billede faroe Nybegynder
22. september 2001 - 15:20 #10
sådan skriver jeg, men databasen åpner i 0,5 sel
og so lukker den
p.s. formen skal altid vere æverst
\'\'\'

Private Sub Form_Load()
Set acc = CreateObject(\"Access.Application\")
   
acc.OpenCurrentDatabase FilePath:=\"C:\\Detailskipan\\Detailskipan.mdw\"

acc.Visible = True
End Sub

\'\'\'
Avatar billede terry Ekspert
22. september 2001 - 15:23 #11
Yes you coúld use a timer for clsoing the EXE.

Add a timer control to the form and set the interval to 5000 (milliseconds) 5 seconds.

Set the enabled to False

After the acc.visible or shellexecute

set the timer enabled property to True

in the timer event quit the applicatin.
Avatar billede terry Ekspert
22. september 2001 - 15:27 #12
The problem is that the acc object is going out of scope. I suggest you try th eother method using ShellExecute.
If you were not going to quit the EXE application then you could make the acc object as a global variable. But because you are closing the EXE the acc object is getting \"closed\" too. So as I said try the ShellExecute.
Avatar billede faroe Nybegynder
23. september 2001 - 17:51 #13
Tusen tak får hjelpen :)
Jeg er ny med vb programmet so dette tar lit tid til at fået lavet det første gang.

P.S. terry, har du prøvet accessTOvb programmet.
(spørgsmål under access)
Avatar billede terry Ekspert
23. september 2001 - 19:49 #14
Thanks faroe!
No I never did try AccessToVB. I looked at those links but it looked like I needed a key(code) or something.
Have you tried it yourself? If you have it then can you send me a copy and I will take a look.
But as I also said in the other question, I doubt that it will be able to convert everything.
There are so many properties in Access thaht I just CAN NOT believe they can be converted without problem. Bút then I can learn something.

mvh
Terry
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
Kurser inden for grundlæggende programmering

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