thaburner
asked on
Public Prodecure & Enum
When I use the insertlog prod. it puts the Number of the Enum ex. LoggedIn = 0 so it saves the Log Type as 0 and not LoggedIn. How can I fix this so it will put logged in and not 0?
Public Enum LogTypes
LoggedIn
LoggedOut
ClientError
ServerError
SignOff
EmployeeControl
HR_Employees
Password_Changed
Other
Delete_Que
Customer
Vendor
CreatedNewHazMat
'Add New Logtypes in the frmLog_Delete form
End Enum
Public Function InsertLog(eLogTypes As LogTypes, strDescription As String, Optional bInsertInStatusBar As Boolean)
On Error Resume Next
On Error GoTo errHandler
Dim reRS As MYSQL_RS
Dim reConn As MYSQL_CONNECTION
Set reRS = New MYSQL_RS
Set reConn = New MYSQL_CONNECTION
If PingServer = True Then
reConn.OpenConnection strSvrAddress, strMySQLUsername, strMySQLPassword, strSvrSchema, strSvrPort
reRS.OpenRs "SELECT * FROM log_database", reConn
Else
RBox ServerNotFound_Ping
End If
reRS.AddNew
reRS.Fields("LogType") = eLogTypes
reRS.Fields("EmployeeID") = CurrentUser.UserInfo_Emplo yeeID
reRS.Fields("EmployeeName" ) = CurrentUser.UserInfo_FullN ame
reRS.Fields("Date") = Format(Date, "mmm. dd/yyyy")
reRS.Fields("Time") = Format(Time, "hh:mm:ss")
reRS.Fields("Description") = strDescription
reRS.Update
If bInsertInStatusBar = True Then
Status strDescription
End If
reRS.CloseRecordset
reConn.CloseConnection
Set reRS = Nothing
Set reConn = Nothing
errHandler:
If Err.Number <> 0 Then
EBox Err.Number, Err.Description, Sql, "SQLGetData #" & Erl, "MySQL_Mod.", "GetData"
End If
End Function
Public Enum LogTypes
LoggedIn
LoggedOut
ClientError
ServerError
SignOff
EmployeeControl
HR_Employees
Password_Changed
Other
Delete_Que
Customer
Vendor
CreatedNewHazMat
'Add New Logtypes in the frmLog_Delete form
End Enum
Public Function InsertLog(eLogTypes As LogTypes, strDescription As String, Optional bInsertInStatusBar As Boolean)
On Error Resume Next
On Error GoTo errHandler
Dim reRS As MYSQL_RS
Dim reConn As MYSQL_CONNECTION
Set reRS = New MYSQL_RS
Set reConn = New MYSQL_CONNECTION
If PingServer = True Then
reConn.OpenConnection strSvrAddress, strMySQLUsername, strMySQLPassword, strSvrSchema, strSvrPort
reRS.OpenRs "SELECT * FROM log_database", reConn
Else
RBox ServerNotFound_Ping
End If
reRS.AddNew
reRS.Fields("LogType") = eLogTypes
reRS.Fields("EmployeeID") = CurrentUser.UserInfo_Emplo
reRS.Fields("EmployeeName"
reRS.Fields("Date") = Format(Date, "mmm. dd/yyyy")
reRS.Fields("Time") = Format(Time, "hh:mm:ss")
reRS.Fields("Description")
reRS.Update
If bInsertInStatusBar = True Then
Status strDescription
End If
reRS.CloseRecordset
reConn.CloseConnection
Set reRS = Nothing
Set reConn = Nothing
errHandler:
If Err.Number <> 0 Then
EBox Err.Number, Err.Description, Sql, "SQLGetData #" & Erl, "MySQL_Mod.", "GetData"
End If
End Function
This may be it as well...
reRS.Fields("LogType") = eLogTypes.LoggedIn 'Added .LoggedIn
reRS.Fields("LogType") = eLogTypes.LoggedIn 'Added .LoggedIn
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
when vb compiles, it will change all string to number. No way you can retrieve the string after compiled to exe format
ASKER
jmundsack i used your GetEnumMemberName Function that worked perfect ya it is a little tideous but it does the trick.
Thanks
Thanks
Public Function InsertLog(eLogTypes As LogTypes, strDescription As String, Optional bInsertInStatusBar As Boolean) As Boolean
'Your Code
'If something then
InsertLog = True
'else
InsertLog = False
'End If
End Function