Link to home
Start Free TrialLog in
Avatar of thaburner
thaburnerFlag for United States of America

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_EmployeeID
        reRS.Fields("EmployeeName") = CurrentUser.UserInfo_FullName
        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
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

I'm really not sure if this helps you, but with a function you have to define it AS a variable, then you can set it to whatever in your code...

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
This may be it as well...

        reRS.Fields("LogType") = eLogTypes.LoggedIn  'Added .LoggedIn
ASKER CERTIFIED SOLUTION
Avatar of jmundsack
jmundsack
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
when vb compiles, it will change all string to number. No way you can retrieve the string after compiled to exe format
Avatar of thaburner

ASKER

jmundsack i used your GetEnumMemberName Function that worked perfect ya it is a little tideous but it does the trick.
Thanks