ronymaxwell
Registered User.
- Local time
- Today, 03:59
- Joined
- Apr 27, 2012
- Messages
- 18
I have a table called 'WORDLIST' containing a list of words and code to copy words from that table to another called 'temp' according to criteria inputted on a form. Any non-alphabetic character is treated as a wildcard. A list box on the form then displays the selected words. The problem is with the last of the Update queries before I add the words to the table 'temp'. It eliminates the words I want as well, leaving nothing. I can't see why it won't work, probably something to do with my logic.
s = Text6.Text '[this is the input from the form]
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE WORDLIST SET fIncludeWord = 1;" '[it starts by marking all words as included]
For I = 1 To Len(s)
j = Asc(Mid$(s, I, 1))
If j < 63 Or j = 64 Or (j > 90 And j < 97) Or j > 122 Then
If I = 1 Then
s = "?" & Mid$(s, 2)
ElseIf I = Len(s) Then
s = Left$(s, Len(s) - 1) & "?"
Else
s = Left$(s, I - 1) & "?" & Mid$(s, I + 1)
End If
End If
Next I
Text6.Text = s '[that just converts non-alphabetic characters to a question mark, ie, wildcards]
L = Len(s)
DoCmd.RunSQL "UPDATE WORDLIST SET fIncludeWord = 0 WHERE Len(fWord) <> " & L & ";" '[the words of incorrect length are eliminated]
For I = 1 To L
j = Asc(Mid$(s, I, 1))
r = Mid$(s, I, 1)
If (j > 64 And j < 91) Or (j > 96 And j < 123) Then
DoCmd.RunSQL "UPDATE WORDLIST SET fIncludeWord = 0 WHERE fIncludeWord = 1 And 'Mid$(fWord, " & I & ", 1)' <> " & Chr$(34) & r & Chr$(34) & ";" '[I want to eliminate words without the specific characters in the correct position. It eliminates everything???]
End If
Next I
DoCmd.RunSQL "DELETE * FROM temp;"
DoCmd.RunSQL "INSERT INTO temp SELECT * FROM WORDLIST WHERE fIncludeWord = 1;"
List21.Requery
I would be grateful for assistance. Thank you.
s = Text6.Text '[this is the input from the form]
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE WORDLIST SET fIncludeWord = 1;" '[it starts by marking all words as included]
For I = 1 To Len(s)
j = Asc(Mid$(s, I, 1))
If j < 63 Or j = 64 Or (j > 90 And j < 97) Or j > 122 Then
If I = 1 Then
s = "?" & Mid$(s, 2)
ElseIf I = Len(s) Then
s = Left$(s, Len(s) - 1) & "?"
Else
s = Left$(s, I - 1) & "?" & Mid$(s, I + 1)
End If
End If
Next I
Text6.Text = s '[that just converts non-alphabetic characters to a question mark, ie, wildcards]
L = Len(s)
DoCmd.RunSQL "UPDATE WORDLIST SET fIncludeWord = 0 WHERE Len(fWord) <> " & L & ";" '[the words of incorrect length are eliminated]
For I = 1 To L
j = Asc(Mid$(s, I, 1))
r = Mid$(s, I, 1)
If (j > 64 And j < 91) Or (j > 96 And j < 123) Then
DoCmd.RunSQL "UPDATE WORDLIST SET fIncludeWord = 0 WHERE fIncludeWord = 1 And 'Mid$(fWord, " & I & ", 1)' <> " & Chr$(34) & r & Chr$(34) & ";" '[I want to eliminate words without the specific characters in the correct position. It eliminates everything???]
End If
Next I
DoCmd.RunSQL "DELETE * FROM temp;"
DoCmd.RunSQL "INSERT INTO temp SELECT * FROM WORDLIST WHERE fIncludeWord = 1;"
List21.Requery
I would be grateful for assistance. Thank you.