flavo
asked on
Update frontend {mde}
Hey all, after a few ideas..
Here's the se-up
Access 97 on Win 2000 Pro
mde frontend on users C:\ {in same location}
mdb backend on network drive
Basically what i want to do is update the mde if i find a bug / add something new
Here's my idea..
Have a Verison table in the backend that stores the current version of the mde that should be used
Have a similar table in the frontend that has the mde current version.
When the frontend is loaded, check to see if it's the right version, if it is, carry on happily, if its not
then i want to update (delete and copy) a new frontend to the user's pc.
My logic seems ok to me, but how do i go about it???
I thought about something like:
Docmd.Quit
'then running a bat file / some VB to delete the current mde and replace the new one.
Haven't fully tested as its at work, but i tired
Docmd.Quit
Msgbox "test"
and no love, no msgbox.. My thinking is that i'd need to close the mde before copying a new one.. anyway to do this?
Any ideas on how to do this??? Dont really want to use replica's, but if i need to i supose i could
Cheers!
Dave
Here's the se-up
Access 97 on Win 2000 Pro
mde frontend on users C:\ {in same location}
mdb backend on network drive
Basically what i want to do is update the mde if i find a bug / add something new
Here's my idea..
Have a Verison table in the backend that stores the current version of the mde that should be used
Have a similar table in the frontend that has the mde current version.
When the frontend is loaded, check to see if it's the right version, if it is, carry on happily, if its not
then i want to update (delete and copy) a new frontend to the user's pc.
My logic seems ok to me, but how do i go about it???
I thought about something like:
Docmd.Quit
'then running a bat file / some VB to delete the current mde and replace the new one.
Haven't fully tested as its at work, but i tired
Docmd.Quit
Msgbox "test"
and no love, no msgbox.. My thinking is that i'd need to close the mde before copying a new one.. anyway to do this?
Any ideas on how to do this??? Dont really want to use replica's, but if i need to i supose i could
Cheers!
Dave
ASKER
>> just a thought, when you quit Access, how do you know whether to update the frontend or not?
the idea was basically
Function needUpdates() as Boolean
If mdeVersion <> mdbVersion Then
Docmd.Quit
'run some bat file or the like to update and re-open the mde
Else
'continue normally
Endif
and run it in the Autoexex macro
the idea was basically
Function needUpdates() as Boolean
If mdeVersion <> mdbVersion Then
Docmd.Quit
'run some bat file or the like to update and re-open the mde
Else
'continue normally
Endif
and run it in the Autoexex macro
what if the versions were the same and you quit access? that was all, it was just something I was confused about
do you know what I mean?
maybe Im still confused here
if you start access, check for updates
if update required then quit
if you start access, check for updates
if no update required, run normally, then user selected quit to end app
do you know what I mean?
maybe Im still confused here
if you start access, check for updates
if update required then quit
if you start access, check for updates
if no update required, run normally, then user selected quit to end app
ASKER
if you start access, check for updates
if update required then quit
and update the mde, (i'm assuming you cant overwrite the mde while its still open - pritty sure about that one)
if you start access, check for updates
if no update required, run normally, then user selected quit to end app
Runs like nothing ever happened
idea?
if update required then quit
and update the mde, (i'm assuming you cant overwrite the mde while its still open - pritty sure about that one)
if you start access, check for updates
if no update required, run normally, then user selected quit to end app
Runs like nothing ever happened
idea?
yea, but Im confused about the ending part, I understand the logic in checking for versions, its what happens after Im a little confused about
say you have a batchfile which runs access and performs updates,
when you quit access, how do you know whether to run the update or not, can Access set a return value?
thats what Im confused about
say you have a batchfile which runs access and performs updates,
when you quit access, how do you know whether to run the update or not, can Access set a return value?
thats what Im confused about
why checking from within the IDE?
Create a simple batch file as starter for your app.
The batch looks first in a defined folder on your network, if a file named your.mde is there.
If not, no new version is existing
if yes, this is the new version. Copy it to the desired local folder by overwriting the existing one.
Last step is always calling your.mde
We have had a similar problem in the past. An application which was delivered to about 100+ workstations. Every update was a pain in the ass!
However, this solution worked quite good. Although we later (as we changed the network into a Active Directory Domain) we implemented a distribution method over roles.
Happy DOS-coding :-))
Greetings
Andy
Create a simple batch file as starter for your app.
The batch looks first in a defined folder on your network, if a file named your.mde is there.
If not, no new version is existing
if yes, this is the new version. Copy it to the desired local folder by overwriting the existing one.
Last step is always calling your.mde
We have had a similar problem in the past. An application which was delivered to about 100+ workstations. Every update was a pain in the ass!
However, this solution worked quite good. Although we later (as we changed the network into a Active Directory Domain) we implemented a distribution method over roles.
Happy DOS-coding :-))
Greetings
Andy
ASKER
>> when you quit access, how do you know whether to run the update or not, can Access set a return value?
>> thats what Im confused about
That's the bit i was looking for help with... not sure how to go about it at all!..
Any ideas about any way of doing it are fine.. open fully to ideas, mine was just an idea, that now seems to be unworkable..
IT-Schubertz,
Maybe the way.... Really would rather do it in Access, if i can...
>> thats what Im confused about
That's the bit i was looking for help with... not sure how to go about it at all!..
Any ideas about any way of doing it are fine.. open fully to ideas, mine was just an idea, that now seems to be unworkable..
IT-Schubertz,
Maybe the way.... Really would rather do it in Access, if i can...
ok, Dave now I gotcha
well I dont think its possible within Access, you could try this if you really wanted to do it in access, not elegant, but should do the trick
if your function to check for updates,
if update required, then create a temporary file, say "c:\updatereq", then quit
then in your batchfile, after you run access, check for existence of this file
if file exists, delete this file, copy new frontend, restart access
well I dont think its possible within Access, you could try this if you really wanted to do it in access, not elegant, but should do the trick
if your function to check for updates,
if update required, then create a temporary file, say "c:\updatereq", then quit
then in your batchfile, after you run access, check for existence of this file
if file exists, delete this file, copy new frontend, restart access
sorry, typo, should be
in your function to check for updates
not
if your function to check for updates
in your function to check for updates
not
if your function to check for updates
ASKER
Going to bed, talk about it in the AM (T minus 10 hours) when i get to work.. feel free to keep posting to give me something to play with while drinking my coffee!
Cheers!
Dave
Cheers!
Dave
@rockiroads,
this is basically my advise, only making it a bit more complicated :-)
Think about the problems that come to my mind:
1. You have two locations concerning the update process which would have to be maintained:
the access logic for comparing the version information and the batch file for copying and restarting access.
2. If you call the batch file and then quit access (which - as we all know would have to happen in this order), how can you assure that the new version already got copied?
While executing the batch file, Access will probably shut down in this moment. So, unfortunately the -soon to be replaced- mde is still in use.
The batch file would run over that problem and restart Access, but you will still have the old application.
A solution would be a timer which will wait some seconds, but nah! that's not nice style.
So, implementing the logic directly in a batch file (could also be a VB script btw) is the most elegant thing.
Greetings
Andy
this is basically my advise, only making it a bit more complicated :-)
Think about the problems that come to my mind:
1. You have two locations concerning the update process which would have to be maintained:
the access logic for comparing the version information and the batch file for copying and restarting access.
2. If you call the batch file and then quit access (which - as we all know would have to happen in this order), how can you assure that the new version already got copied?
While executing the batch file, Access will probably shut down in this moment. So, unfortunately the -soon to be replaced- mde is still in use.
The batch file would run over that problem and restart Access, but you will still have the old application.
A solution would be a timer which will wait some seconds, but nah! that's not nice style.
So, implementing the logic directly in a batch file (could also be a VB script btw) is the most elegant thing.
Greetings
Andy
Hi Andy, yep that could be the case
The use of a temp file was the idea behind the soluton, like I said not elegant
how you implement it is a different matter, Dave wanted it within Access so I just gave the example solution in Access,
your solution is also valid
The use of a temp file was the idea behind the soluton, like I said not elegant
how you implement it is a different matter, Dave wanted it within Access so I just gave the example solution in Access,
your solution is also valid
I have used the same approach as Andy in the past but if you really want to do this with Access then what you need is an intermediary database that checks the version, does the copy if necessary and then launches the resulting file. I have used this method also, you can make a nice splash screen wioth the company logo and the "please wait while updating" label if you need to copy the file down. Think about how you can use this to "distribute" all of you front-ends and I bet you come up with a nice little tool. Let me know if I can help with any of the particulars.
Steve
Steve
I did not want to point out that my solution is valid. I did it to show the flaws I see in your suggestion. No offense intended.
I think it is impossible to do in Access itself.
I think it is impossible to do in Access itself.
Andy, no offence taking, I know why solution isnt perfect, and with creating temporary files there will be flaws
you need to check if file created etc etc etc and all the palarva that goes with it
I thought about Steve's idea as well but thought it might be more hassle having two mdb's, e.g. db change
though the splash screen idea is good
you need to check if file created etc etc etc and all the palarva that goes with it
I thought about Steve's idea as well but thought it might be more hassle having two mdb's, e.g. db change
though the splash screen idea is good
I have been doing this with my application that needs update.
As Steve have pointed out,
a second mde to do the copying of the new mde.
From the StartUp form of the Application mde.
Private Sub Form_Load()
CheckUpdate ' this is just one of the routine at startup
End Sub
Private Sub CheckUpdate()
Dim DestPath, ServerPath
ServerPath = "\\Server01-08\DBFolder\up date.mde"
DestPath = "C:\Documents and Settings\" & Me.txtUserName & "\Applicat\update.mde"
On Error GoTo ChkUpdateError
If Me!LocRev.Value <> Me!Rev.Value Then
FileCopy ServerPath, DestPath ' copies the the second mde {update.mde}
CheckVersion
Else
Exit Sub
End If
Exit_ChkUpdateError:
Exit Sub
ChkUpdateError:
MsgBox Err.Description
Resume Exit_ChkUpdateError
End Sub
==============
Private Sub CheckVersion()
Dim Db As DAO.Database
Dim oApp As New Access.Application
If Me!LocRev.Value <> Me!Rev.Value Then 'Verifies rev again before opening the update.mde
oApp.Visible = True
Set Db = oApp.DBEngine.OpenDatabase ("C:\Docum ents and Settings\" & Me.txtUserName & "\Applicat\update.mde")
oApp.OpenCurrentDatabase ("C:\Documents and Settings\" & Me.txtUserName & "\Applicat\update.mde")
Db.Close
Set Db = Nothing
Else
Exit Sub
End If
DoCmd.Quit 'Quit the application , now you can replace the mde. update.mde executes the copying
' of the updated application mde.
End Sub
my $0.02
As Steve have pointed out,
a second mde to do the copying of the new mde.
From the StartUp form of the Application mde.
Private Sub Form_Load()
CheckUpdate ' this is just one of the routine at startup
End Sub
Private Sub CheckUpdate()
Dim DestPath, ServerPath
ServerPath = "\\Server01-08\DBFolder\up
DestPath = "C:\Documents and Settings\" & Me.txtUserName & "\Applicat\update.mde"
On Error GoTo ChkUpdateError
If Me!LocRev.Value <> Me!Rev.Value Then
FileCopy ServerPath, DestPath ' copies the the second mde {update.mde}
CheckVersion
Else
Exit Sub
End If
Exit_ChkUpdateError:
Exit Sub
ChkUpdateError:
MsgBox Err.Description
Resume Exit_ChkUpdateError
End Sub
==============
Private Sub CheckVersion()
Dim Db As DAO.Database
Dim oApp As New Access.Application
If Me!LocRev.Value <> Me!Rev.Value Then 'Verifies rev again before opening the update.mde
oApp.Visible = True
Set Db = oApp.DBEngine.OpenDatabase
oApp.OpenCurrentDatabase ("C:\Documents and Settings\" & Me.txtUserName & "\Applicat\update.mde")
Db.Close
Set Db = Nothing
Else
Exit Sub
End If
DoCmd.Quit 'Quit the application , now you can replace the mde. update.mde executes the copying
' of the updated application mde.
End Sub
my $0.02
ASKER
I ave seen this at work,,
Open mde, msgbox says -> Your not using current version. Then it closes, runs a bat file, then opens the mde again {from the bat file}
Ideas??
Ill look into it al little more.. Try and find the Access guy, hes hard to catch, very hard
Open mde, msgbox says -> Your not using current version. Then it closes, runs a bat file, then opens the mde again {from the bat file}
Ideas??
Ill look into it al little more.. Try and find the Access guy, hes hard to catch, very hard
Drop me a line and i'll send you the update.mdb
Hey guys,
I'm not the best at creating batch files but there is a guy here at work that really is great at it.
I'm pretty positive you can do this.
On Load
Check for version
If version is different then open batch file
First thing batch file does is kill the current running process of Access MDE.
Then it does an xcopy of the MDE from the network to the c drive
Then it launches the new MDE.
If you want me to ask my friend here at work how to create this batch file I will do so!
Also, any ideas why this wouldn't work?
Chris
I'm not the best at creating batch files but there is a guy here at work that really is great at it.
I'm pretty positive you can do this.
On Load
Check for version
If version is different then open batch file
First thing batch file does is kill the current running process of Access MDE.
Then it does an xcopy of the MDE from the network to the c drive
Then it launches the new MDE.
If you want me to ask my friend here at work how to create this batch file I will do so!
Also, any ideas why this wouldn't work?
Chris
ASKER
Tested and this worked.. needs a little work, but you'll get the idea.. Still need to do the checking to see if it needs updating, but thats the easy bit..
Sub test()
Shell "cmd.exe /c d:\db\test.bat"
DoCmd.Quit
End Sub
test.bat ----->
SLEEP 3
del "d:\db\db1.mdb"
copy D:\db-test\db1-test.mdb d:\db\db1-test.mdb
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE " "d:\db\db1-test.mdb"
<---- test.bat
Seems to work, just glad for once VB doesnt wait for the shell to end before coninuing on its merry way..
Sub test()
Shell "cmd.exe /c d:\db\test.bat"
DoCmd.Quit
End Sub
test.bat ----->
SLEEP 3
del "d:\db\db1.mdb"
copy D:\db-test\db1-test.mdb d:\db\db1-test.mdb
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE
<---- test.bat
Seems to work, just glad for once VB doesnt wait for the shell to end before coninuing on its merry way..
ASKER
% Krys,
% you want me to ask my friend here at work how to create this batch file I will do so!
Can do it... have a few examples at work, but thanks anyway..
Here's the "real way", just wanted a little tester first
@echo off
set PROGRAM_NAME=My program
set LOCAL_DIR=c:\somewhere\
set NETWORK_DIR=\\server\dir\
set MDE_FILENAME=MyProgram.mde
set SHORTCUT_NAME=MyProgram.ln k
echo .....
echo %PROGRAM_NAME% Update in progress
echo ....
echo .
if not exist %LOCAL_DIR%\%MDE_FILENAME% goto MakeLocalDir
goto StartOS
:MakeLocalDir
echo New Installation
mkdir %LOCAL_DIR%
echo .
:StartOS
%NETWORK_DIR%\sleep 5
if "%OS%"=="Windows_NT" goto NT
if "%OS%"=="" goto Win95
goto end
:NT
if NOT "%ALLUSERSPROFILE%"=="" goto Win2000
echo Windows NT
if exist "%userprofile%\desktop\%SH ORTCUT_NAM E%" goto NT_a
goto NT_b
:NT_a
del "%userprofile%\desktop\%SH ORTCUT_NAM E%"
:NT_b
copy "%NETWORK_DIR%\%SHORTCUT_N AME%" "%windir%\Profiles\All Users\desktop"
echo .
goto copymde
:Win2000
echo Windows 2000
if exist "%userprofile%\desktop\%SH ORTCUT_NAM E%" goto Win2000_a
goto Win2000_b
:Win2000_a
del "%userprofile%\desktop\%SH ORTCUT_NAM E%"
:Win2000_b
copy "%NETWORK_DIR%\%SHORTCUT_N AME%" "%ALLUSERSPROFILE%\desktop "
echo .
goto copymde
:Win95
echo Windows 95
copy "%NETWORK_DIR%\%SHORTCUT_N AME%" "%windir%\Profiles\%USR%\d esktop"
if exist "%windir%\Profiles\%USR%\d esktop" goto Win95_a
goto Win95_b
:Win95_a
del "%windir%\Profiles\%USR%\d esktop"
:Win95_b
copy "%NETWORK_DIR%\%SHORTCUT_N AME%" "%windir%\desktop"
echo .
goto copymde
:copymde
copy %NETWORK_DIR%\%MDE_FILENAM E% %LOCAL_DIR%
echo .
goto end
:end
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE " %LOCAL_DIR%\%MDE_FILENAME%
echo ....
echo ... The update is now complete. This window can now be closed.
echo ....
echo Thank you.
echo ....
% you want me to ask my friend here at work how to create this batch file I will do so!
Can do it... have a few examples at work, but thanks anyway..
Here's the "real way", just wanted a little tester first
@echo off
set PROGRAM_NAME=My program
set LOCAL_DIR=c:\somewhere\
set NETWORK_DIR=\\server\dir\
set MDE_FILENAME=MyProgram.mde
set SHORTCUT_NAME=MyProgram.ln
echo .....
echo %PROGRAM_NAME% Update in progress
echo ....
echo .
if not exist %LOCAL_DIR%\%MDE_FILENAME%
goto StartOS
:MakeLocalDir
echo New Installation
mkdir %LOCAL_DIR%
echo .
:StartOS
%NETWORK_DIR%\sleep 5
if "%OS%"=="Windows_NT" goto NT
if "%OS%"=="" goto Win95
goto end
:NT
if NOT "%ALLUSERSPROFILE%"=="" goto Win2000
echo Windows NT
if exist "%userprofile%\desktop\%SH
goto NT_b
:NT_a
del "%userprofile%\desktop\%SH
:NT_b
copy "%NETWORK_DIR%\%SHORTCUT_N
echo .
goto copymde
:Win2000
echo Windows 2000
if exist "%userprofile%\desktop\%SH
goto Win2000_b
:Win2000_a
del "%userprofile%\desktop\%SH
:Win2000_b
copy "%NETWORK_DIR%\%SHORTCUT_N
echo .
goto copymde
:Win95
echo Windows 95
copy "%NETWORK_DIR%\%SHORTCUT_N
if exist "%windir%\Profiles\%USR%\d
goto Win95_b
:Win95_a
del "%windir%\Profiles\%USR%\d
:Win95_b
copy "%NETWORK_DIR%\%SHORTCUT_N
echo .
goto copymde
:copymde
copy %NETWORK_DIR%\%MDE_FILENAM
echo .
goto end
:end
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE
echo ....
echo ... The update is now complete. This window can now be closed.
echo ....
echo Thank you.
echo ....
Looks good Flavo!
Let me know how it worked.
Chris
Let me know how it worked.
Chris
ASKER
Will be a while, putting the job on hold for a while..
exam time!!!
ASKER
2pm (T minus 7 hours...) Dont really care, only mid-sem and im sooo over it, last subject, then another peice of paper and a few more letters after my name..
Dave.
Dave.
Ok guys, I am having a problem trying to implement this.
When I run the bat file from Windows Explorer, it works great.
When I call it using VBA with this code, it doesn't work correctly. It will still copy, but to my C:\WINNT folder.
Call Shell(Environ$("COMSPEC") & " /c M:\SQLSTAF\Test.bat", vbNormalFocus)
The problem is under "Tools>Options>General" my default database folder is set to a UNC server share. \\Server\Folder
Cmd.exe when called from access can't use the UNC share and defaults to WinNT. Here is the error at the top of the batch file when it runs. Please note that it still runs the batch file, it just copies the database to the C:\WINNT folder.
'\\Server\Folder'
CMD.EXE was started with the above path as the current directory.
UNC Paths are not supported. Defaulting to the Windows Directory.
Now, when I change the default database folder to have a C:\ the batch file runs perfectly. Unfortunately this setting will be different with all my users and the default is to a server share (\\server\folder) so it wont work for them. Is there any way around this?
Also, if this needs to be in a different question, let me know and Ill post it there.
Chris
When I run the bat file from Windows Explorer, it works great.
When I call it using VBA with this code, it doesn't work correctly. It will still copy, but to my C:\WINNT folder.
Call Shell(Environ$("COMSPEC") & " /c M:\SQLSTAF\Test.bat", vbNormalFocus)
The problem is under "Tools>Options>General" my default database folder is set to a UNC server share. \\Server\Folder
Cmd.exe when called from access can't use the UNC share and defaults to WinNT. Here is the error at the top of the batch file when it runs. Please note that it still runs the batch file, it just copies the database to the C:\WINNT folder.
'\\Server\Folder'
CMD.EXE was started with the above path as the current directory.
UNC Paths are not supported. Defaulting to the Windows Directory.
Now, when I change the default database folder to have a C:\ the batch file runs perfectly. Unfortunately this setting will be different with all my users and the default is to a server share (\\server\folder) so it wont work for them. Is there any way around this?
Also, if this needs to be in a different question, let me know and Ill post it there.
Chris
ASKER
I had a lot of probelms getting it to work in Access to, worked in DOS, not Access.. Here;s what im using now (havent tested the "real one"
Shell "cmd.exe /c d:\db\test.bat"
DoCmd.Quit
bat file
SLEEP 1
del "d:\db\db1.mdb"
copy D:\db-test\db1-test.mdb d:\db\db1-test.mdb
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE " "d:\db\db1-test.mdb"
I had to play around with the " " a little bit to get it all to work.. If you want the SLEEP.exe i can put it up somewhere {free from MS i think...}
Dave
Shell "cmd.exe /c d:\db\test.bat"
DoCmd.Quit
bat file
SLEEP 1
del "d:\db\db1.mdb"
copy D:\db-test\db1-test.mdb d:\db\db1-test.mdb
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE
I had to play around with the " " a little bit to get it all to work.. If you want the SLEEP.exe i can put it up somewhere {free from MS i think...}
Dave
Congratulations Dave, your in the Top15 again (actually Ive just noticed)
if its just a problem with Shell, why not try ShellExecute, dont know if it makes a difference though, but I thought I'd throw it in.
If its not Shell anymore, Where is the problem now?
run it like this LaunchApp "d:\db\test.bat",WIN_MIN
Private Declare Function ShellExecuteAPI 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
'***App Window Constants***
Public Const WIN_NORMAL = 1 'Open Normal
Public Const WIN_MAX = 3 'Open Maximized
Public Const WIN_MIN = 2 'Open Minimized
'***Error Codes***
Private Const ERROR_SUCCESS = 32&
Private Const ERROR_NO_ASSOC = 31&
Private Const ERROR_OUT_OF_MEM = 0&
Private Const ERROR_FILE_NOT_FOUND = 2&
Private Const ERROR_PATH_NOT_FOUND = 3&
Private Const ERROR_BAD_FORMAT = 11&
Public Function LaunchApp(stFile As String, lShowHow As Long, Optional sPars As String = vbNullString)
Dim lRet As Long, vTaskID As Variant
Dim sRet As String
'First try ShellExecute
lRet = ShellExecuteAPI(hWndAccess App, vbNullString, stFile, sPars, vbNullString, lShowHow)
If lRet > ERROR_SUCCESS Then
sRet = vbNullString
lRet = -1
Else
Select Case lRet
Case ERROR_NO_ASSOC:
'Try the OpenWith dialog
vTaskID = Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " _
& stFile, WIN_NORMAL)
lRet = (vTaskID <> 0)
Case ERROR_OUT_OF_MEM:
sRet = "Error: Out of Memory/Resources. Couldn't Execute!"
Case ERROR_FILE_NOT_FOUND:
sRet = "Error: File not found. Couldn't Execute!"
Case ERROR_PATH_NOT_FOUND:
sRet = "Error: Path not found. Couldn't Execute!"
Case ERROR_BAD_FORMAT:
sRet = "Error: Bad File Format. Couldn't Execute!"
Case Else:
End Select
If sRet <> vbNullString Then MsgBox sRet
End If
LaunchApp = lRet & _
IIf(sRet = "", vbNullString, ", " & sRet)
End Function
if its just a problem with Shell, why not try ShellExecute, dont know if it makes a difference though, but I thought I'd throw it in.
If its not Shell anymore, Where is the problem now?
run it like this LaunchApp "d:\db\test.bat",WIN_MIN
Private Declare Function ShellExecuteAPI 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
'***App Window Constants***
Public Const WIN_NORMAL = 1 'Open Normal
Public Const WIN_MAX = 3 'Open Maximized
Public Const WIN_MIN = 2 'Open Minimized
'***Error Codes***
Private Const ERROR_SUCCESS = 32&
Private Const ERROR_NO_ASSOC = 31&
Private Const ERROR_OUT_OF_MEM = 0&
Private Const ERROR_FILE_NOT_FOUND = 2&
Private Const ERROR_PATH_NOT_FOUND = 3&
Private Const ERROR_BAD_FORMAT = 11&
Public Function LaunchApp(stFile As String, lShowHow As Long, Optional sPars As String = vbNullString)
Dim lRet As Long, vTaskID As Variant
Dim sRet As String
'First try ShellExecute
lRet = ShellExecuteAPI(hWndAccess
If lRet > ERROR_SUCCESS Then
sRet = vbNullString
lRet = -1
Else
Select Case lRet
Case ERROR_NO_ASSOC:
'Try the OpenWith dialog
vTaskID = Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " _
& stFile, WIN_NORMAL)
lRet = (vTaskID <> 0)
Case ERROR_OUT_OF_MEM:
sRet = "Error: Out of Memory/Resources. Couldn't Execute!"
Case ERROR_FILE_NOT_FOUND:
sRet = "Error: File not found. Couldn't Execute!"
Case ERROR_PATH_NOT_FOUND:
sRet = "Error: Path not found. Couldn't Execute!"
Case ERROR_BAD_FORMAT:
sRet = "Error: Bad File Format. Couldn't Execute!"
Case Else:
End Select
If sRet <> vbNullString Then MsgBox sRet
End If
LaunchApp = lRet & _
IIf(sRet = "", vbNullString, ", " & sRet)
End Function
if test.bat doesnt exit, maybe you need to put a exit statement in (thats if one is not already there)
ASKER
rocki,
I did get it working, just a pain to get the bat file working from Access, eventhough it worked from the DOS prompt.
Krys was having some prob's getting his version to work.
>> Congratulations Dave, your in the Top15 again (actually Ive just noticed)
Means im on here not doing work that i sohuld be doing :-(
Dave
I did get it working, just a pain to get the bat file working from Access, eventhough it worked from the DOS prompt.
Krys was having some prob's getting his version to work.
>> Congratulations Dave, your in the Top15 again (actually Ive just noticed)
Means im on here not doing work that i sohuld be doing :-(
Dave
ASKER
heres the final code -
this function is called in the AutoExec macro
tblLocalVersion is locacl to the mde, tblCurrentVersion is linked from the BE. Also has a little routine to copy the shorcut if they deleted it
Function CheckVersion()
On Error Resume Next
Dim db As DAO.Database
Dim rsLocal As DAO.Recordset
Dim rsCurrent As DAO.Recordset
Set db = CurrentDb
Set rsLocal = db.OpenRecordset("tblLocal Version")
Set rsCurrent = db.OpenRecordset("tblCurre ntVersion" )
If rsLocal(0) <> rsCurrent(0) Then
'not same version, need to update
MsgBox "You are not using the current version. " & rsCurrent(0) & " will now be installed", vbCritical
Shell "cmd.exe /c " & Chr(34) & "\\server\path\Update.vbs" & Chr(34), vbHide
DoCmd.Quit
End If
'clean up
db.Close
rsLocal.Close
rsCurrent.Close
Set db = Nothing
Set rsLocal = Nothing
Set rsCurrent = Nothing
End Function
'************************* ********** ********** ********** ********** *****
then Update.vbs :
'************************* ********** ********** ********** ********** *****
Option Explicit
'
'
Dim wait
Dim WshShell
Dim Return
Dim FSO
Dim sUserProf
Const sLocalFolder = "C:\CD_Email\"
Const sMDE = "EmailMgmt.mde"
Const sNetworkPath = "\\server\path\Update\"
Const sLink = "\\server\path\Update\Emai l Mgmt.lnk"
Set WshShell = CreateObject("Wscript.Shel l")
sUserProf = WshShell.ExpandEnvironment Strings("% userprofil e%")
wait = 2
wait_function(wait)
Set FSO = CreateObject("Scripting.Fi leSystemOb ject")
If Not FSO.FolderExists(sLocalFol der) Then
FSO.CreateFolder(sLocalFol der)
FSO.CopyFile sLink, sUserProf & "\Desktop\Email Mgmt.lnk", True
Set FSO = Nothing
End If
Update sNetworkPath, sLocalFolder, sMDE
WshShell.Run chr(34) & "C:\Program Files\Microsoft Office\Office\Msaccess.exe " & chr(34) & " " & sLocalFolder & sMDE
Set WshShell = Nothing
Private Sub wait_function(secs)
Dim enter_time, leave_time
enter_time = Timer
leave_time = Timer
While (enter_time + secs > leave_time)
leave_time = Timer
Wend
End Sub
Private Sub Update(sNetworkPath, sLocalFolder, sMDE)
Dim FSO
On Error Resume Next
Set FSO = CreateObject("Scripting.Fi leSystemOb ject")
FSO.CopyFile sNetworkPath & sMDE, sLocalFolder & sMDE, True
'clean up
Set FSO = Nothing
End Sub
'************************* ********** ********** ********** ********** *****
then just for the heck of it, my way of installing it on the local PC
'************************* ********** ********** ********** ********** *****
Option Explicit
Dim WshShell
Dim Return
Dim FSO
Dim sUserProf
Dim lResp
On Error Resume Next
Const sLocalFolder = "C:\CD_Email\"
Const sMDE = "EmailMgmt.mde"
Const sNetworkPath = "\\server\path\DataBase\Up date\"
Const sLink = "server\path\Database\Upda te\Email Mgmt.lnk"
Const sLinkFile = "Email Mgmt.lnk"
Set WshShell = CreateObject("Wscript.Shel l")
sUserProf = WshShell.ExpandEnvironment Strings("% userprofil e%")
Set FSO = CreateObject("Scripting.Fi leSystemOb ject")
If Not FSO.FolderExists(sLocalFol der) Then
FSO.CreateFolder(sLocalFol der)
End If
FSO.CopyFile sLink, sUserProf & "\Desktop\" & sLinkFile, True
Set FSO = Nothing
Update sNetworkPath, sLocalFolder, sMDE
lResp = MsgBox("Installation is complete." & chr(10) & "Do you wish to start the application now?", vbYesNo, "????")
If lResp = vbYes Then
WshShell.Run chr(34) & "C:\Program Files\Microsoft Office\Office\Msaccess.exe " & chr(34) & " " & sLocalFolder & sMDE
End If
'clean up
Set WshShell = Nothing
Private Sub Update(sNetworkPath, sLocalFolder, sMDE)
Dim FSO
On Error Resume Next
Set FSO = CreateObject("Scripting.Fi leSystemOb ject")
FSO.CopyFile sNetworkPath & sMDE, sLocalFolder & sMDE, True
'clean up
Set FSO = Nothing
End Sub
Dave!
this function is called in the AutoExec macro
tblLocalVersion is locacl to the mde, tblCurrentVersion is linked from the BE. Also has a little routine to copy the shorcut if they deleted it
Function CheckVersion()
On Error Resume Next
Dim db As DAO.Database
Dim rsLocal As DAO.Recordset
Dim rsCurrent As DAO.Recordset
Set db = CurrentDb
Set rsLocal = db.OpenRecordset("tblLocal
Set rsCurrent = db.OpenRecordset("tblCurre
If rsLocal(0) <> rsCurrent(0) Then
'not same version, need to update
MsgBox "You are not using the current version. " & rsCurrent(0) & " will now be installed", vbCritical
Shell "cmd.exe /c " & Chr(34) & "\\server\path\Update.vbs"
DoCmd.Quit
End If
'clean up
db.Close
rsLocal.Close
rsCurrent.Close
Set db = Nothing
Set rsLocal = Nothing
Set rsCurrent = Nothing
End Function
'*************************
then Update.vbs :
'*************************
Option Explicit
'
'
Dim wait
Dim WshShell
Dim Return
Dim FSO
Dim sUserProf
Const sLocalFolder = "C:\CD_Email\"
Const sMDE = "EmailMgmt.mde"
Const sNetworkPath = "\\server\path\Update\"
Const sLink = "\\server\path\Update\Emai
Set WshShell = CreateObject("Wscript.Shel
sUserProf = WshShell.ExpandEnvironment
wait = 2
wait_function(wait)
Set FSO = CreateObject("Scripting.Fi
If Not FSO.FolderExists(sLocalFol
FSO.CreateFolder(sLocalFol
FSO.CopyFile sLink, sUserProf & "\Desktop\Email Mgmt.lnk", True
Set FSO = Nothing
End If
Update sNetworkPath, sLocalFolder, sMDE
WshShell.Run chr(34) & "C:\Program Files\Microsoft Office\Office\Msaccess.exe
Set WshShell = Nothing
Private Sub wait_function(secs)
Dim enter_time, leave_time
enter_time = Timer
leave_time = Timer
While (enter_time + secs > leave_time)
leave_time = Timer
Wend
End Sub
Private Sub Update(sNetworkPath, sLocalFolder, sMDE)
Dim FSO
On Error Resume Next
Set FSO = CreateObject("Scripting.Fi
FSO.CopyFile sNetworkPath & sMDE, sLocalFolder & sMDE, True
'clean up
Set FSO = Nothing
End Sub
'*************************
then just for the heck of it, my way of installing it on the local PC
'*************************
Option Explicit
Dim WshShell
Dim Return
Dim FSO
Dim sUserProf
Dim lResp
On Error Resume Next
Const sLocalFolder = "C:\CD_Email\"
Const sMDE = "EmailMgmt.mde"
Const sNetworkPath = "\\server\path\DataBase\Up
Const sLink = "server\path\Database\Upda
Const sLinkFile = "Email Mgmt.lnk"
Set WshShell = CreateObject("Wscript.Shel
sUserProf = WshShell.ExpandEnvironment
Set FSO = CreateObject("Scripting.Fi
If Not FSO.FolderExists(sLocalFol
FSO.CreateFolder(sLocalFol
End If
FSO.CopyFile sLink, sUserProf & "\Desktop\" & sLinkFile, True
Set FSO = Nothing
Update sNetworkPath, sLocalFolder, sMDE
lResp = MsgBox("Installation is complete." & chr(10) & "Do you wish to start the application now?", vbYesNo, "????")
If lResp = vbYes Then
WshShell.Run chr(34) & "C:\Program Files\Microsoft Office\Office\Msaccess.exe
End If
'clean up
Set WshShell = Nothing
Private Sub Update(sNetworkPath, sLocalFolder, sMDE)
Dim FSO
On Error Resume Next
Set FSO = CreateObject("Scripting.Fi
FSO.CopyFile sNetworkPath & sMDE, sLocalFolder & sMDE, True
'clean up
Set FSO = Nothing
End Sub
Dave!
ASKER
I was going to close this with points going to you guys, but really, i think i did it myself. please feel free to differ. Im going to close with refund.
you should ask for refund, dave
;-)
;-)
ASKER
I dont think the Q should be deleted, there is some very good info in this, and very helpfull to others.
I think PAQ and refund is the way to go.
Anyone else interseted in my method?? thought it was better than using 2 db's as a FE.
Dave
I think PAQ and refund is the way to go.
Anyone else interseted in my method?? thought it was better than using 2 db's as a FE.
Dave
ASKER
ee_ai_construct,
the code i posted @ 07/15/2004 02:23PM EST (Australian East Standard Time) is where the "the same content is in other questions" first came from. Its up to you what you do with the PAQ / delete option, but i think you will be lossing some very valuable info on how the method was derived if you chose to delete. It seems to be that most experts have previously used 2 db's (ie. Stevbe, capricon1 {two of the highest experts in this TA} and IT-Schubertz) to do the same thing that i have done in 1.
Dave.
the code i posted @ 07/15/2004 02:23PM EST (Australian East Standard Time) is where the "the same content is in other questions" first came from. Its up to you what you do with the PAQ / delete option, but i think you will be lossing some very valuable info on how the method was derived if you chose to delete. It seems to be that most experts have previously used 2 db's (ie. Stevbe, capricon1 {two of the highest experts in this TA} and IT-Schubertz) to do the same thing that i have done in 1.
Dave.
No objections here,
Im happy for the refund, but if this is supposed to be a knowledge sharing exercise, surely it would be better to leave this PAQed rather than to delete it. Its not just the answer but the build up to the answer, that is the extra knowledge in this question
ee_ai_construct, from the original question,there is the answer provided by flavo plus a few alternatives, even though none were satisfactory, it can give some ideas to people reading this on many ways of tackling a problem
Im happy for the refund, but if this is supposed to be a knowledge sharing exercise, surely it would be better to leave this PAQed rather than to delete it. Its not just the answer but the build up to the answer, that is the extra knowledge in this question
ee_ai_construct, from the original question,there is the answer provided by flavo plus a few alternatives, even though none were satisfactory, it can give some ideas to people reading this on many ways of tackling a problem
i agree with dave and rocki
;-)rey
;-)rey
ASKER
Thanks rock and cap.
usually 2 is better than 1, but in this case its not. The sol~n works and has been tested with several app's with 400+ users, no problems as yet.
Dave!
usually 2 is better than 1, but in this case its not. The sol~n works and has been tested with several app's with 400+ users, no problems as yet.
Dave!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks ee_ai_construct!!!
Dave
Dave
or are you running another program to check?
you could do this, if version numbers differ then put up a message box saying
"the "app title" client has been updated. Please go to Start/Programs/<App>/Updat
then do application.quit
so basically when you install the DB's on the user's PC's, have a shortcut which runs a batch file
this batchfile wil perform your copy