Understanding Code

Prayder

Registered User.
Local time
Today, 05:26
Joined
Mar 20, 2013
Messages
303
I am trying to understand as much as possible when writing code so I was hoping someone might be able to explain to me exactly what this is saying:



Code:
  Private Sub Form_Load()
If Version <> Forms![Version]![Version subform].Form![Version2] Then
    Dim stAppName As String
    stAppName = "O:\WWP Shared\Databases\Install_files\Inventory_mgr.bat"
    Call Shell(stAppName, 1)
    DoCmd.Quit
End If
End Sub
 
if the version you are using is not the correct version THEN

run the named .bat file and quit the access application.


now - I assume the .bat file is intended to collect the latest version, but i am not 100% sure whether the version you are using will be (ie can be) replaced by the new version while you are actually using it. (if that is what the .bat file does)
 
Further, I'd be very surprised if the code you listed worked. Shell does not accept paths with spaces.

Call Shell(Chr(34) & stAppName & Chr(34), 1)

should make it work.
 
ok so what exactly does

Code:
  Call Shell(Chr(34) & stAppName & Chr(34), 1)



do?
 
ok so what exactly does

Code:
  Call Shell(Chr(34) & stAppName & Chr(34), 1)



do?

It adds " " around your file name making it read:
Call Shell("blah\blah blah2\blah\blah.bat"

rather than:
Call Shell (blah\blah blah2\blah\blah.bat)

The first will work, the 2nd won't because of the space.
chr(##) = ASCII code call. 34 being a "
 

Users who are viewing this thread

Back
Top Bottom