The msg function was just an example.
I suppose to know if a function was "successful" depends on what the
function actually does right?
There is no a universal way to know if the function was successful?
What I am trying to do is a Switchboard for my many ms access apps, some
excel and intranet websites
I was thinking that it would be usefull to keep track how many times a app
is use it. So if a app was suscessfully open increase the counter.
Here is my function and how i call it.
Thanks for you help!!!!
'SUB---------------------------------------------------------------------------------------
Sub List2_KeyDown(KeyCode As Integer, Shift As Integer)
On Error GoTo Err_List2_KeyDown
Dim uname As String
Dim sql As String
Dim thepath As String
If KeyCode = 13 Then
uname = VBA.Environ("USERNAME")
sql = "select count(*) as CC from sys_swsub where sys_id = " & Me.SYS_ID & "
AND sys_user = '" & uname & "'"
CurrentDb.QueryDefs("INTRANET").sql = sql
Select Case DLookup("[CC]", "INTRANET")
Case 0
Responce = MsgBox("Access Denied. Please contact your Sys Admin. ",
vbCritical, " CORP")
Exit Sub
Case Else
Responce = open_app(Me.sys_app, Me.sys_path, Me.sys_ext)
'MsgBox thepath
End Select
End If
Exit_List2_KeyDown:
Exit Sub
Err_List2_KeyDown:
If Err.Number = 3146 Then
Responce = MsgBox("Appliction Error. Please contact your sys
admin. ", vbCritical, " CORP")
Exit Sub
End If
Resume Exit_List2_KeyDown
End Sub
'FUNCTION----------------------------------------------------------------------------------------
Public Function open_app(theapp As String, thepath As String, theext As
String)
On Error GoTo Err_open_app
Dim ie As Object
Dim uname As String
Dim thepathapp As String
'----------------------------------------------
' Open Application
'----------------------------------------------
uname = VBA.Environ("USERNAME")
thepathapp = thepath & uname & theext
Select Case theapp
Case "MSACCESS"
Call Shell("msaccess.exe """ & thepathapp & """", 1)
DoCmd.Quit
Case "MSEXCEL"
Call Shell("excel.exe """ & thepathapp & """", 1)
DoCmd.Quit
Case "MSWORD"
Call Shell("word.exe """ & thepathapp & """", 1)
DoCmd.Quit
Case "IE"
Set ie = CreateObject("InternetExplorer.Application")
ie.AddressBar = False
ie.MenuBar = True
ie.Toolbar = True
ie.Width = 1024
ie.Height = 768
ie.Left = 0
ie.Top = 0
ie.navigate thepath
ie.resizable = True
ie.Visible = True
Set ie = Nothing
DoCmd.Quit
Case Else
Responce = MsgBox("Application Error.", vbCritical, " UMCORP")
Exit Function
End Select
Exit_open_app:
Exit Function
Err_open_app:
MsgBox Err.Description
Resume Exit_open_app
End Function