Recently Split Database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dan2kx
    Contributor
    • Oct 2007
    • 365

    #16
    Thanks NeoPa, i must credit you on the Checkloop syntax which you gave me in a previous post; (http://bytes.com/topic/access/answer...e-reopen-db-vb), i also add another line on mine to resolve hidden files

    Code:
    Attrib -H "FileName" 
    *Code*
    Attrib +H "Filename"

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #17
      I see. Yes that probably helped a bit.

      What I was referring to though, was the way you created the CMD file in your Access VBA code. I don't recall helping with that (although I've contributed to a few threads on a variety of topics in my time so it's hard to be positive). That's certainly good to see and I was impressed.

      Comment

      • csolomon
        New Member
        • Mar 2008
        • 166

        #18
        Originally posted by Dan2kx
        Hi, the following code which (for me) runs on startup

        Code:
        Function VersionCheck() As Boolean
        Dim VN As Integer, meVN As Integer, fn As String, MDEfn As String
            VN = DMax("Version", "tblVersion")
                'DoCmd.RunSQL "UPDATE tblVersion SET tblVersion.Version = " & VN + 1 & ";"
            MDEfn = """" & DLookup("MDEfn", "tblVersion", "Version = " & VN) & """"
            meVN = 2
            If VN <> meVN Then
            VersionCheck = True
            MsgBox "The version you are currently using has been superseded by another;" & vbCrLf & _
                    "The program will close and retrieve the latest version before continuing.", vbCritical, "Program Update Available..."
                fn = FolderFromPath(CurrentDb.Name) & "Update.cmd"
                Open fn For Output As #1
                Print #1, ":CheckLoop1"
                Print #1, "Copy " & MDEfn & " " & """" & CurrentDb.Name & """" & " / y "
                Print #1, "If ErrorLevel 1 GoTo CheckLoop1"
                Print #1, """" & CurrentDb.Name & """"
                Print #1, "Del " & """" & fn & """" & " /f"
                Close 1#
            Call Shell(fn, 1)
            DoCmd.Quit acQuitSaveAll
            End If
        End Function
        Code:
        Public Function FolderFromPath(strFullPath As String) As String
            FolderFromPath = Left(strFullPath, InStrRev(strFullPath, "\"))
        End Function
        I have a linked table "tblVersion ", that stores a number which can be changed obv. and the path to the updated file, mde/mbd. this function holds a hard coded value (to be changed on new release), if the values dont match then the function writes a batchfile, closes access and the batch runs. it is very crude and has the potential for error (because of the loop, but you could put a counter in) but i like it.
        i hope this is clear and can help you,
        --Hi Dan, Thanks for the post.

        I noticed you had "and the path to the updated file, mde/mbd", does that mean this will not work with Access 2007, which has the file type .accde? Also this code is put in when the DB starts? Where would that code go? In a module or and update event somewhere.

        Thank you

        Comment

        • Dan2kx
          Contributor
          • Oct 2007
          • 365

          #19
          sorry i meant put the path to file (with the extension),

          you could hard write that too if you require, i choose to store that in the version table and use a dlookup.

          WRT location of code, you can put it where ever you want, what i posted was a function, so this can go in a module, and you simply need to refer to
          Code:
          VersionCheck
          in some code that runs on startup, alternatively you can just use the code on its own (remove top and bottom Function lines).

          i use an auto exec macro (in a2003) that runs on startup some other "Startup()" code and the VersionCheck resides there, you could have a form load on startup and have this code in the On Load/Open etc (of the form)

          Good luck, let me know if you need any further advice

          Dan

          Comment

          Working...