How to input a string in another column based on the data in another column?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shawnnnnnnn
    New Member
    • Nov 2014
    • 36

    How to input a string in another column based on the data in another column?

    Hi all,

    I need to input a string into a column named "EventType" . The code should first check if the column "Agent Name" contains any strings. If there is none, it will input "IBM Director" into the EventType column.

    Once it has looped through the agent names, the code will then loop through the Details column and input into EventTypes based on what is displayed within the string.

    These are the codes that I am using to achieve this, however nothing is being input into the EventType column. What am I doing wrong?

    Code:
    Private Sub Command11_Click()
        Dim dbs As DAO.Database
        Dim rst As DAO.Recordset
        
        Set dbs = CurrentDb
        Set rst = dbs.OpenRecordset("Final")
        
        If Not rst.EOF Then
            Do
                rst.Edit
                If InStr(rst![AgentName], " ") Then
                    rst![EventType] = "IBM Director"
                End If
                rst.Update
                rst.MoveNext
            Loop Until rst.EOF
        End If
        If Not rst.EOF Then
            Do
                rst.Edit
                If InStr(rst![Details], ">>>>") Then
                    rst![EventType] = "TEC Notice"
                ElseIf InStr(rst![Details], "SERVICE NOT RUNNING") Then
                    rst![EventType] = "Wintel Services"
                ElseIf InStr(rst![Details], "_ntService") Then
                    rst![EventType] = "Wintel Services"
                ElseIf InStr(rst![Details], "LOGICAL DRIVE UTIL") Then
                    rst![EventType] = "Winte Logical Disk"
                ElseIf InStr(rst![Details], "ntDiskFree") Then
                    rst![EventType] = "Winte Logical Disk"
                ElseIf InStr(rst![Details], "Ntdriveutil") Then
                    rst![EventType] = "Winte Logical Disk"
                ElseIf InStr(rst![Details], "FILESYSTEM:") Then
                    rst![EventType] = "Unix/Linux Filesystems"
                ElseIf InStr(rst![Details], "Filesysuse") Then
                    rst![EventType] = "Unix/Linux Filesystems"
                ElseIf InStr(rst![Details], "CPU OFFLINE:") Then
                    rst![EventType] = "UNIX CPU Offline"
                ElseIf InStr(rst![Details], "Missing") Then
                    rst![EventType] = "Unix/Linux Process"
                ElseIf InStr(rst![Details], "CPU UTILIZATION:") Then
                    rst![EventType] = "CPU Utilization"
                ElseIf InStr(rst![Details], "errpt") Then
                    rst![EventType] = "INFRA Logfile"
                ElseIf InStr(rst![Details], "SWAP") Then
                    rst![EventType] = "UNIX/Linux Memory"
                ElseIf InStr(rst![Details], "Thrashing:") Then
                    rst![EventType] = "UNIX/Linux Memory"
                ElseIf InStr(rst![Details], "realmem") Then
                    rst![EventType] = "UNIX/Linux Memory"
                ElseIf InStr(rst![Details], "PAGING SPACE:") Then
                    rst![EventType] = "Wintel Memory"
                ElseIf InStr(rst![Details], "nonpage") Then
                    rst![EventType] = "Wintel Memory"
                ElseIf InStr(rst![Details], "Ntmem") Then
                    rst![EventType] = "Wintel Memory"
                ElseIf InStr(rst![Details], "oqsql") Then
                    rst![EventType] = "Database"
                ElseIf InStr(rst![Details], "DB2DIAG") Then
                    rst![EventType] = "Database"
                ElseIf InStr(rst![Details], "uddb2") Then
                    rst![EventType] = "Database"
                ElseIf InStr(rst![Details], "Zombie") Then
                    rst![EventType] = "UNIX/Linux Zombie Process"
                ElseIf InStr(rst![Details], "uxphysicalmem") Then
                    rst![EventType] = "UNIX/Linux Memory"
                ElseIf InStr(rst![Details], "uxPageScan") Then
                    rst![EventType] = "UNIX/Linux Memory"
                ElseIf InStr(rst![Details], "ntCPUUtilization") Then
                    rst![EventType] = "CPU Utilization"
                ElseIf InStr(rst![Details], "same process") Then
                    rst![EventType] = "Wintel Process"
                ElseIf InStr(rst![Details], "_ntproc") Then
                    rst![EventType] = "Wintel Process"
                ElseIf InStr(rst![Details], "Event_ID") Then
                    rst![EventType] = "Wintel Eventlog"
                ElseIf InStr(rst![Details], "MQ error") Then
                    rst![EventType] = "INFRA Logfile"
                ElseIf InStr(rst![Details], "MQMONITORLOG") Then
                    rst![EventType] = "INFRA Logfile"
                ElseIf InStr(rst![Details], "_MSG") Then
                    rst![EventType] = "INFRA Logfile"
                ElseIf InStr(rst![Details], "logline") Then
                    rst![EventType] = "Other logfile"
                ElseIf InStr(rst![Details], "strscan") Then
                    rst![EventType] = "Other logfile"
                ElseIf InStr(rst![Details], "NTSrvc") Then
                    rst![EventType] = "Wintel Services"
                ElseIf InStr(rst![Details], "Ntdrivutil") Then
                    rst![EventType] = "Winte Logical Disk"
                ElseIf InStr(rst![Details], "uxFilesys") Then
                    rst![EventType] = "Unix/Linux Filesystems"
                ElseIf InStr(rst![Details], ":") Then
                    rst![EventType] = "Others"
                End If
                rst.Update
                rst.MoveNext
            Loop Until rst.EOF
        End If
    End Sub
  • shawnnnnnnn
    New Member
    • Nov 2014
    • 36

    #2
    UPDATE:

    I think the problem lies with the code that checks the agent name. When I removed it, it managed to populate the EventType column based on the details. But I still need to find out how to check the agent name too.

    Comment

    Working...