F
Fred Boer
Hello!
I am trying to set up a table of application settings which would allow the
user to set certain values. At the moment I am working on setting up the
application name. I know that the user can set an application name using the
standard Access Options, but in addition, I want the user's choice of an
application name to be reflected in my generic error handling. So... I
thought about creating a table "tblSettings"; (SettingsID, SettingText,
SettingDescription), ("1", "My Little Library","ApplicationName"). I use a
generic error handling process in all subs. When the errorhandling code
runs, I want to be able to pull the value of the application name from the
table, and insert it into the messagebox that pops up in response to the
error. I'm not sure of the best way to "pull the value from the table",
however. I've done something that appears to work, but I wonder: is this the
best way to do it, using a recordset? Is there a better approach?
(Note: I am aware that this code will pull information from the first record
in the table.)
Public Function fncErrorMessage(errNumber As Long, errDescription As String)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblSettings")
Dim strAppName As String
strAppName = rs("SettingText")
Dim Msg As String
Msg = "An error has occurred." & vbCr & vbCr & "Error Type: " &
errDescription & vbCr & vbCr & "Error Number: " & errNumber & vbCr & vbCr &
"Please contact the Database Administrator immediately."
msgbox Msg, vbExclamation, strAppName ' *** Here is where I want to
put the application name....
End Function
I am trying to set up a table of application settings which would allow the
user to set certain values. At the moment I am working on setting up the
application name. I know that the user can set an application name using the
standard Access Options, but in addition, I want the user's choice of an
application name to be reflected in my generic error handling. So... I
thought about creating a table "tblSettings"; (SettingsID, SettingText,
SettingDescription), ("1", "My Little Library","ApplicationName"). I use a
generic error handling process in all subs. When the errorhandling code
runs, I want to be able to pull the value of the application name from the
table, and insert it into the messagebox that pops up in response to the
error. I'm not sure of the best way to "pull the value from the table",
however. I've done something that appears to work, but I wonder: is this the
best way to do it, using a recordset? Is there a better approach?
(Note: I am aware that this code will pull information from the first record
in the table.)
Public Function fncErrorMessage(errNumber As Long, errDescription As String)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblSettings")
Dim strAppName As String
strAppName = rs("SettingText")
Dim Msg As String
Msg = "An error has occurred." & vbCr & vbCr & "Error Type: " &
errDescription & vbCr & vbCr & "Error Number: " & errNumber & vbCr & vbCr &
"Please contact the Database Administrator immediately."
msgbox Msg, vbExclamation, strAppName ' *** Here is where I want to
put the application name....
End Function