Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validation

Status
Not open for further replies.

n0795

Programmer
Jul 30, 2001
136
US
I can validate on word of a field but not more than that,
How do i validate multiple words so a user cannot enter them.
 
I don't understand your question, could you elaborate a little more? Table/query/form/control/field names are helpful as well as examples. Joe Miller
joe.miller@flotech.net
 
Well I have a website with a form that puts the user data into the database.
the fields are NAME,ADD,COMMENTS
Really what I want is that if they enter a bad word into the comments field Access will change that word to lets say ****
So I would have a list of pre determined words which it would change
But im not sure you are able to do that in Access

If not what I can do at the moment is open the table in design view and edit the Comments field with the validation key but it only seems to work for one word and not multiple.
Thanks
Nick
 
Not sure if this helps but, this function will search a string for a substring and allow you to replace it with another string. You can run a loop that checks each value in your "bad word" table and run it against the string.

[tt]
Function fstrTran(ByVal sInString As String, _
sFindString As String, _
sReplaceString As String) As String
Dim iSpot As Integer, iCtr As Integer
Dim iCount As Integer

iCount = Len(sInString)
For iCtr = 1 To iCount
iSpot = InStr(1, sInString, sFindString)
If iSpot > 0 Then
sInString = Left(sInString, iSpot - 1) & _
sReplaceString & _
Mid(sInString, iSpot + Len(sFindString))
Else
Exit For
End If
Next
fstrTran = sInString

End Function
[/tt]

Sample Usage
Result = fstrTran(MyString,"BadWord", "B******")

HTH Joe Miller
joe.miller@flotech.net
 
Thanks joe Does the code need any input from me and where do i put it.
Forgive me but im kinda new to Access
 
The is not the complete solution, simply a part of it. As for where the code goes, I have no idea, you'll have to answer that question. I have little experience with using Access as a backend for web pages so I can't help you there. I would venture to guess that you have some kind of import or posting process to put the data in your tables. This process should be done before that point in time.

HTH Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top