Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 10th, 2004, 05:22 AM
dimd80 dimd80 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Greece, Athens
Posts: 29 dimd80 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 21 m 41 sec
Reputation Power: 0
Send a message via Yahoo to dimd80
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

Reply With Quote
  #2  
Old August 10th, 2004, 09:27 AM
spak111 spak111 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 349 spak111 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 25 sec
Reputation Power: 5
Send a message via AIM to spak111
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.

Reply With Quote
  #3  
Old August 11th, 2004, 06:21 AM
dimd80 dimd80 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Greece, Athens
Posts: 29 dimd80 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 21 m 41 sec
Reputation Power: 0
Send a message via Yahoo to dimd80
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.

Reply With Quote
  #4  
Old August 11th, 2004, 09:59 AM
spak111 spak111 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 349 spak111 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 25 sec
Reputation Power: 5
Send a message via AIM to spak111
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.

Reply With Quote
  #5  
Old August 11th, 2004, 12:58 PM
dimd80 dimd80 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Greece, Athens
Posts: 29 dimd80 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 21 m 41 sec
Reputation Power: 0
Send a message via Yahoo to dimd80
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?

Reply With Quote
  #6  
Old August 12th, 2004, 08:56 AM
spak111 spak111 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 349 spak111 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 25 sec
Reputation Power: 5
Send a message via AIM to spak111
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.

Reply With Quote
  #7  
Old August 12th, 2004, 04:39 PM
dimd80 dimd80 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Greece, Athens
Posts: 29 dimd80 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 21 m 41 sec
Reputation Power: 0
Send a message via Yahoo to dimd80
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!?

Reply With Quote
  #8  
Old August 13th, 2004, 08:13 AM
spak111 spak111 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 349 spak111 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 25 sec
Reputation Power: 5
Send a message via AIM to spak111
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.

Reply With Quote
  #9  
Old September 27th, 2005, 02:38 PM
Jim Lally Jim Lally is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 1 Jim Lally User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 10 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > execute - run mdb file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT