help perform this action only once
I need some help on the best way to code the following actions so that they only fire one time. Currently I have them in the sub form load and an error handler.
VB Code:
Private Sub Form_Load()
On Error GoTo FormLoadError
'---------------------------------------
'delete the flash shortcut
Dim shell As Object
Dim link As Object
Dim DesktopPath As String
Set shell = CreateObject("WScript.Shell")
DesktopPath = shell.SpecialFolders("AllUsersDesktop")
fso.DeleteFile DesktopPath & "\Agent Prospecting Presentation.lnk"
'create a new flash shortcut
'because we are replacing the old exe
Set shell = CreateObject("WScript.Shell")
DesktopPath = shell.SpecialFolders("AllUsersDesktop")
Set link = shell.CreateShortcut(DesktopPath & "\Agent Prospecting Presentation.lnk")
'link.Arguments = "1 2 3"
link.Description = "Agent Prospecting Presentation"
'link.HotKey = "CTRL+ALT+SHIFT+X"
link.IconLocation = "C:\WestfieldInsurance\Westfield_1to1F_v1.exe,1"
link.TargetPath = "C:\MyWestfieldPresentation\Westfield_1to1F_v1.exe"
'window style 3=maximized, 2=normal
link.WindowStyle = 2
'start in
link.WorkingDirectory = "C:\MyWestfieldPresentation"
link.Save
'this code modifies the existing database without overwriting user data
'create new table
Call CreateConnection(objConn)
objConn.Execute "CREATE TABLE TempDocAudio(n_id TEXT(50))"
Call CloseConnection(objConn)
'modify Documents and Campaign tables
Call CreateConnection(objConn)
objConn.Execute "ALTER TABLE Documents ADD COLUMN n_mp3 TEXT(50)"
'cannot use default parameters with ODBC connectivity must switch to OLEDB
objConn.Execute "ALTER TABLE Documents ADD COLUMN n_wavBol TEXT(50)DEFAULT FALSE"
'add wespak and defender columns
objConn.Execute "ALTER TABLE Campaign ADD COLUMN c_wespakOn TEXT(50)DEFAULT 1"
objConn.Execute "ALTER TABLE Campaign ADD COLUMN c_defenderOn TEXT(50)DEFAULT 1"
Call CloseConnection(objConn)
'delete from bios Bud Leister and Reg Stith
Call CreateConnection(objConn)
objConn.Execute "DELETE FROM Bios WHERE b_name=""Bud Leister"" OR b_name=""Reg Stith"""
'MsgBox ("deleted")
Call CloseConnection(objConn)
' Error handler
FormLoadError:
If Err.Number <> 0 Then
errLogger Err.Number, Err.Description, "This error created on:"
'Debug.Print errLogger
Err.Clear
Resume Next
'Exit Sub
End If
End Sub
Re: help perform this action only once
Before doing anything, check to see if TempDocAudio already exists. If it does, then don't do anything else because your routine has probably already run.
That would be my quess as to how you could tell if it had or had not been run before.
Re: help perform this action only once
Well then the same would be true for the desktop icon path. If the path has already been set, then everything else has probably run as well. :)
Re: help perform this action only once
Quote:
Originally Posted by Navarone
Well then the same would be true for the desktop icon path. If the path has already been set, then everything else has probably run as well. :)
Ok...that works too. The thing is that something won't exist before running it for the first time that will exist after running it for the first time, so as long as your procedure checks for something before doing anything, then you should be in business.