Hello
I am comparing an array word to two different tables if the word is in one of the tables then I increase the count of that word, if the word is not in either table I add the word to a specific table. I thought I had the code figure out but I am getting a Runtime Error, any help would be appreciated.
The words have to be in uppercase to match the table.
I get the error message at this point
I am comparing an array word to two different tables if the word is in one of the tables then I increase the count of that word, if the word is not in either table I add the word to a specific table. I thought I had the code figure out but I am getting a Runtime Error, any help would be appreciated.
The words have to be in uppercase to match the table.
Code:
Private Sub DescProblem_LostFocus()
Dim rs As Recordset
Dim rs1 As Recordset
Dim rs2 As Recordset
Dim strSQL As String
Dim mySQL As String
Dim strArray() As String
Dim UCaseWord As String
Dim x As Integer
'Split text into array from description problem textbox
strArray = Split(DescProblem)
For x = 0 To UBound(strArray)
'Change strArray to UPPERCASE
UCaseWord = UCase(strArray(x))
'Query tbl_IndexedWord_Not_Used
strSQL = "SELECT * FROM tbl_IndexedWord_Not_Used WHERE tbl_IndexedWord_Not_Used = '" & UCaseWord & "'"
Set rs = CurrentDb.OpenRecordset(strSQL)
'Test to see if word is in the Not_Used table if not query tbl_IndexedWords and openrecordset
If rs.EOF Then
mySQL = "SELECT * FROM tbl_IndexedWords WHERE tbl_IndexedWords = '" & UCaseWord & "'"
Set rs1 = CurrentDb.OpenRecordset(mySQL)
'Test to see if word is in the IndexedWords table if not then add the word to the IndexedWord table
If rs1.EOF Then
Set rs2 = CurrentDb.OpenRecordset("tbl_IndexedWords")
rs2.AddNew
rs2!Uppercase = UpWordCase
rs2.Update
'If the word is in the tbl_IndexedWords then increase the count by 1
Else
rs1.Edit
rs1!SumOfCount = rs2!SumOfCount + 1
rs1.Update
End If
'If the word is in the tbl_IndexedWord_Not_Used then increase the count by 1
Else
rs.Update
rs!SumOfCount = rs!SumOfCount + 1
rs.Update
End If
Next
'Close all openrecordset
rs.close
rs1.close
rs2.close
End Sub
Code:
Set rs = CurrentDb.OpenRecordset(strSQL)