Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Db Opener Issues 1

Status
Not open for further replies.

newguy86

Technical User
May 19, 2008
226
US
I have two VBScripts (one installs a shortcut for a Db and the other opens it). When I click on the shortcut that my installer script created, the database will open but then immediately close. Can anyone help me figure out what I am doing wrong?

Installer script
Code:
Dim oShell
Dim sDesk
Dim oShortCut
Dim strFileName 

Set oShell = CreateObject("WScript.Shell")
sDesk = oShell.SpecialFolders.Item("Desktop")
Set oShortCut = oShell.CreateShortcut(sDesk & "\Bowen Db.lnk")

With oShortCut
	.TargetPath = "C:\Program Files\Bowen Db Opener.vbs"
	.Description = "Bowen Db"
	.WorkingDirectory = "C:\Program Files\Bowen Db Opener.vbs"
    .Save
End With

MsgBox "Installation Complete!"

Opener script
Code:
Dim lfsobject
Dim dbsLTTFront

On Error Resume Next

Set lfsObject = CreateObject("Scripting.FileSystemObject")
lfsObject.CopyFile "************************\Bowen Db.mdb", "C:\Program Files\Bowen Db.mdb"

If Err.Number = 0 Then
    Set dbsLTTFront = CreateObject("Access.Application")
    'dbsLTTFront.AutomationSecurity = 1 'msoAutomationSecurityLow
    dbsLTTFront.Visible = True
    dbsLTTFront.OpenCurrentDatabase "C:\Program Files\Bowen Db.mdb"
Else
    'Err number 70, 7866 and -2147023170 sometimes occur with rampant clicking
    Msgbox ("The application takes a moment to load, please be patient.")
End If

Any assistance would be greatly appreciated.

Travis

"Why would I ever want to learn about programming when Micorsoft products would be able to handle even the simplest of tasks. Oh...wait a minute...something's wrong with that statement!
 
[0] If you choose to use the automation routine, which is in a sense good, making it free from user's path setting, you can add this line after the .OpenCurrentDatabase line, surrendering control to user.
[tt]
dbsLTTFront.OpenCurrentDatabase "C:\Program Files\Bowen Db.mdb"
[blue]dbsLTTFront.userControl=true[/blue]
[/tt]
[1] Otherwise, you can use .run (replacing the whole section of err.number=0) to get his done, but it would be dependent on the concrete path of the msaccess.
[tt]
createobject("wscript.shell").run "msaccess """ & "C:\Program Files\Bowen Db.mdb" & """"
[/tt]
 
tsuji,
I used the first suggestion that you gave me and it worked perfectly.

Thanks!

Travis

"Why would I ever want to learn about programming when Micorsoft products would be able to handle even the simplest of tasks. Oh...wait a minute...something's wrong with that statement!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top