473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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?

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command11_Click()
  2.     Dim dbs As DAO.Database
  3.     Dim rst As DAO.Recordset
  4.  
  5.     Set dbs = CurrentDb
  6.     Set rst = dbs.OpenRecordset("Final")
  7.  
  8.     If Not rst.EOF Then
  9.         Do
  10.             rst.Edit
  11.             If InStr(rst![AgentName], " ") Then
  12.                 rst![EventType] = "IBM Director"
  13.             End If
  14.             rst.Update
  15.             rst.MoveNext
  16.         Loop Until rst.EOF
  17.     End If
  18.     If Not rst.EOF Then
  19.         Do
  20.             rst.Edit
  21.             If InStr(rst![Details], ">>>>") Then
  22.                 rst![EventType] = "TEC Notice"
  23.             ElseIf InStr(rst![Details], "SERVICE NOT RUNNING") Then
  24.                 rst![EventType] = "Wintel Services"
  25.             ElseIf InStr(rst![Details], "_ntService") Then
  26.                 rst![EventType] = "Wintel Services"
  27.             ElseIf InStr(rst![Details], "LOGICAL DRIVE UTIL") Then
  28.                 rst![EventType] = "Winte Logical Disk"
  29.             ElseIf InStr(rst![Details], "ntDiskFree") Then
  30.                 rst![EventType] = "Winte Logical Disk"
  31.             ElseIf InStr(rst![Details], "Ntdriveutil") Then
  32.                 rst![EventType] = "Winte Logical Disk"
  33.             ElseIf InStr(rst![Details], "FILESYSTEM:") Then
  34.                 rst![EventType] = "Unix/Linux Filesystems"
  35.             ElseIf InStr(rst![Details], "Filesysuse") Then
  36.                 rst![EventType] = "Unix/Linux Filesystems"
  37.             ElseIf InStr(rst![Details], "CPU OFFLINE:") Then
  38.                 rst![EventType] = "UNIX CPU Offline"
  39.             ElseIf InStr(rst![Details], "Missing") Then
  40.                 rst![EventType] = "Unix/Linux Process"
  41.             ElseIf InStr(rst![Details], "CPU UTILIZATION:") Then
  42.                 rst![EventType] = "CPU Utilization"
  43.             ElseIf InStr(rst![Details], "errpt") Then
  44.                 rst![EventType] = "INFRA Logfile"
  45.             ElseIf InStr(rst![Details], "SWAP") Then
  46.                 rst![EventType] = "UNIX/Linux Memory"
  47.             ElseIf InStr(rst![Details], "Thrashing:") Then
  48.                 rst![EventType] = "UNIX/Linux Memory"
  49.             ElseIf InStr(rst![Details], "realmem") Then
  50.                 rst![EventType] = "UNIX/Linux Memory"
  51.             ElseIf InStr(rst![Details], "PAGING SPACE:") Then
  52.                 rst![EventType] = "Wintel Memory"
  53.             ElseIf InStr(rst![Details], "nonpage") Then
  54.                 rst![EventType] = "Wintel Memory"
  55.             ElseIf InStr(rst![Details], "Ntmem") Then
  56.                 rst![EventType] = "Wintel Memory"
  57.             ElseIf InStr(rst![Details], "oqsql") Then
  58.                 rst![EventType] = "Database"
  59.             ElseIf InStr(rst![Details], "DB2DIAG") Then
  60.                 rst![EventType] = "Database"
  61.             ElseIf InStr(rst![Details], "uddb2") Then
  62.                 rst![EventType] = "Database"
  63.             ElseIf InStr(rst![Details], "Zombie") Then
  64.                 rst![EventType] = "UNIX/Linux Zombie Process"
  65.             ElseIf InStr(rst![Details], "uxphysicalmem") Then
  66.                 rst![EventType] = "UNIX/Linux Memory"
  67.             ElseIf InStr(rst![Details], "uxPageScan") Then
  68.                 rst![EventType] = "UNIX/Linux Memory"
  69.             ElseIf InStr(rst![Details], "ntCPUUtilization") Then
  70.                 rst![EventType] = "CPU Utilization"
  71.             ElseIf InStr(rst![Details], "same process") Then
  72.                 rst![EventType] = "Wintel Process"
  73.             ElseIf InStr(rst![Details], "_ntproc") Then
  74.                 rst![EventType] = "Wintel Process"
  75.             ElseIf InStr(rst![Details], "Event_ID") Then
  76.                 rst![EventType] = "Wintel Eventlog"
  77.             ElseIf InStr(rst![Details], "MQ error") Then
  78.                 rst![EventType] = "INFRA Logfile"
  79.             ElseIf InStr(rst![Details], "MQMONITORLOG") Then
  80.                 rst![EventType] = "INFRA Logfile"
  81.             ElseIf InStr(rst![Details], "_MSG") Then
  82.                 rst![EventType] = "INFRA Logfile"
  83.             ElseIf InStr(rst![Details], "logline") Then
  84.                 rst![EventType] = "Other logfile"
  85.             ElseIf InStr(rst![Details], "strscan") Then
  86.                 rst![EventType] = "Other logfile"
  87.             ElseIf InStr(rst![Details], "NTSrvc") Then
  88.                 rst![EventType] = "Wintel Services"
  89.             ElseIf InStr(rst![Details], "Ntdrivutil") Then
  90.                 rst![EventType] = "Winte Logical Disk"
  91.             ElseIf InStr(rst![Details], "uxFilesys") Then
  92.                 rst![EventType] = "Unix/Linux Filesystems"
  93.             ElseIf InStr(rst![Details], ":") Then
  94.                 rst![EventType] = "Others"
  95.             End If
  96.             rst.Update
  97.             rst.MoveNext
  98.         Loop Until rst.EOF
  99.     End If
  100. End Sub
Nov 28 '14 #1
1 837
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.
Nov 28 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jim | last post by:
im using asp.net, C# to enter data into a table in sql server...however im getting this error: Input string was not in a correct format. Description: An unhandled exception occurred during the...
9
by: nsj | last post by:
I am working with a web applicaction that accesses a SQL Server database. I need the value of the 'id' column of the last inserted row in the table 'PERSON'. The SQL statement for that purpose is:...
0
by: phmyhn | last post by:
I have two web pages, one is viewlarger.aspx, another one is shoppingcart.aspx. On the viewlarger.aspx, when clicking "add to cart" image button, the sub appends the id (passed from another page...
8
by: Ottar | last post by:
I have a few numeric fields, and when I update i get the error: "Input string was not in a correct format". Next line:" System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&...
1
by: Mike P | last post by:
Is it possible when populating a datagrid to populate a dropdownlist column based upon the value populated to another row in the datagrid? (i.e. I have a drop down which I want to populate...
1
by: bbasberg | last post by:
Hi, I am wondering how to get a value from one column based on another, using visual basic for applications. Here are the criteria: The first column contains status and we want the next row in...
4
by: khengi | last post by:
Hi, I'm a newbie, so I guess this is a question that expresses my total ignorance, but never the less: I have an old table into which I want to add a column that will automatically update based...
9
by: seep | last post by:
hi i m finding following error on the code that i wants to use to get all record from table via store procedure with paging. the error is : Input string was not in a correct...
4
by: ericjb | last post by:
Hi, I have a table with a column in which I would like to generate random numbers. I know how to use the dbms_random function but don't know how I would do what I want to do. I would like to...
3
by: phanikumar32 | last post by:
Hello all, I have a table in my sql server with column name as'type' and 'Direction' (as shown in image 1). and from this input i want the output as below once. (as shown in image 2). ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.