'----------------- '@author Duncan Rounding - Genesis Technical Ltd - www.genesistechnical.com '@date 2009/07/22 '@version 0.2 '@history '0.1 Initial 2009/04/22 '0.2 folder picking update 2009/07/22 '----------------- 'This script will allow entry of a SQL script and execute it on a selected Microsoft Access database. 'Use at your own risk '----------------- ON ERROR RESUME NEXT siteFolder = pickFolder(0) mydb = siteFolder + "\ActinicCatalog.mdb" sData = InputBox("Copy the SQL query you want to execute into the input box") strAutoset = MsgBox("This will update the selected database with the SQL query." & vbcrlf & vbcrlf & "BACKUP THE YOUR DATABASE BEFORE CONTINUING" & vbcrlf & vbcrlf &"Select 'Yes' to go ahead and update the database - wait for the update to finish." & vbcrlf & "Select 'No' to cancel." ,4) If (strAutoset = vbYes) then Set OBJdbConnection = CreateObject("ADODB.Connection") OBJdbConnection.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & mydb SQLQuery = sData Set Result = OBJdbConnection.Execute(SQLQuery) OBJdbConnection.Close msgbox("Completed - Database updated") Else msgbox("Aborted - Database not updated") End If Function pickFolder(strStartDir) Dim SA, F Set SA = CreateObject("Shell.Application") Set F = SA.BrowseForFolder(0, "Choose the folder that contains the Actinic database you wish to work on.", 0, strStartDir) If (Not F Is Nothing) Then PickFolder = F.Items.Item.path End If Set F = Nothing Set SA = Nothing End Function