|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
execute - run mdb file
hi.
I want to run an exe (writen with Visual Basic 6) that ,sometime, gives the control to an mdb. I mean that: 1)start executing the setup.exe 2)runs... 3)Opens the mdb (in the same folder)(the exe must by hidden) 4)works with the mdb(insert data, make report...)(the exe remain hidden) 5)close mdb 6)the setup.exe continues running. Tried these: * shell(), (but i didnot do anything) and * Dim appname as Access.Application Set appname = CreateObject("Access.Application") appAccess.Application.OpenCurrentDatabase(path\nam e.mdb) appAccess.docmd.openform("frm_start") (the starting form in mdb file) (but again nothing) Any suggestion? Any would appreciate. Thnks |
|
#2
|
|||
|
|||
|
Well, you can do this in a number of different ways, really. Shell won't give you want you want, as it will really only open an executable, not an actual file itself. If you want to do that, you would want to use Windows API. However, you can use Automation, like you were trying to do. The only line of code that you should need to add to it is appname.visible = true. This should allow it so that you actually see access open. I would suggest using this method versus using APIs to open the mdb, as it is a bit more messy (or at least I think so). However, if this does not work for you, please let me know so I can give you the API call.
|
|
#3
|
|||
|
|||
|
Thnks spaks111. The mdb opened. ok.
An other question: When mdb opens, the exe file closes. I mean that , when mdb finished whatever must do, the control does not return to the exe (because it had closed-finished its execution) Is any way to do this. (to keep the exe running in the background and leastening to the mdb, in order to take again control when mdb finish) Thnks for your time. |
|
#4
|
|||
|
|||
|
Well, the best suggestion that I would have for this one would be NOT to close your exe that opens the mdb. This would really be the simplest way to do this. Other wise you would need to write a macro that when the mdb closes, that would re-open the exe file. Along with that, if you are using pure automation for what the mdb is doing, you could have your exe do all the work (add records, create reports) and then automatically close the mdb from your executable so that the user doesn't have to see what's even going on. I hope this helps.
|
|
#5
|
|||
|
|||
|
My problem is that i do not know HOW to keep exe running in the background! It always closes. Is there any way to do this?
|
|
#6
|
|||
|
|||
|
What is the code that you are using to open the mdb? It shouldn't close your exe unless you explicitly tell it to do so. And if it must be hidden, try minimizing it, instead of closing or hiding the form, so you don't have to worry about having to load it again.
|
|
#7
|
|||
|
|||
|
Thnks for your replies.
The code (wrote it again with .Net) Includes 2 modules: Module Module1 Sub Main() openmdb() EndSub EndModule Module Module2 Dim appAccess AsObject Function openmdb() Dim rout1 AsString rout1 = GetSetting("My_Program", "Settings", "path", "no_path") appAccess = CreateObject("Access.Application") appAccess.OpenCurrentDatabase(rout1 & "My_Program.mdb") EndFunction EndModule Opens the mdb but then the exe closes. The same With VB6: Dim appAccess As Access.Application Function openmdb() Setwarning = False Set appAccess = CreateObject("Access.Application") appAccess.OpenCurrentDatabase "D:\My_Program.mdb" appAccess.Visible = True End Function In Vb6 the openmdb() is used in the Form_Load() In both tries, the exe closes!? |
|
#8
|
|||
|
|||
|
Okay, I would suggest taking out the openmdb() function OUT of the Form_Load() event. Put it into a timer control that executes as soon as the form is finished loading. I would have to say that the reason that it closes is because it doesn't allow the load to finish loading before opening up another program. By putting it in a timer control, it will allow the exe form to load completely, then open the mdb. Let me know if this works for you or not. I hope this helps.
|
|
#9
|
|||
|
|||
|
There are quite a few ways to make an .exe program wait until a task has been completed. Almost all involve some type of loop until the called program has completed. You can go the API route and use FindWindow. However, looking at your code I believe the easiest way would be something like:
'The loop below will generate an error when the .mdb has closed. You must trap the error accordingly. If using .net, use the try/catch/finally statements. On error goto Err_PgmCompleted Do While appAccess.CurrentProject.IsConnected appAccess.UserControl = True Loop Err_PgmCompleted: 'Continue with the remainder of the program. |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > execute - run mdb file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|