Searching certain marks

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to read record's field which contains for example "akjjfh 89 dhh". I
will check the line and if it contains "jj" I want to write "jjj" to other
field of the same record. What is the easiest way of doing this?
 
Sam,

Use an Update Query. The SQL view of such a query would look something
like this...
UPDATE YourTable SET OtherField = "jjj" WHERE FirstField Like "*jj*"
 
Ok, here is a code that I tired to make work. It woun't work. I'm pretty new
with vb, so there can some very stupid mistakes.

Dim SQL As String
SQL = "Update FieldControllerModules" & _
"set Table1.field1 = 'JJ'" & _
"where table1.field2 = '*JJJJ*'"
DoCmd.RunSQL
 
Sam,

A few points....

1. This is not a macro, it is a VBA procedure.
2. Your SQL is missing a couple of spaces.
3. Your RunSQL line doesn't refer to the SQL.
4. What is "FieldControllerModules"? The syntax of the SQL doesn't
really make sense. What comes after the UPDATE word is the name of the
table that you are updating. Is FieldControllerModules the name of the
table? If so, what is Table1?

Try it like this...
Dim SQL As String
SQL = "UPDATE table1" & _
" SET field1 = 'JJ'" & _
" WHERE field2 = '*JJJJ*'"
DoCmd.RunSQL SQL
 
Ok, thanks guys. I'm little bit lost with this thing, but yes I posted this
in wrong section. The main thing now is that code runs, but it doesn't find
the "jj" from the record field so it doesn't write to any field either.
 
Sam,

The query we have been discussing is looking for records where jjjj is
included in field2... is that what you mean by the "record field"? And
then if it finds it, it will write jj to the field1 in the same table.
I guess this illustrates one of the disadvantages of naming such as
table1 and field1. If you still can't get it, please post back with
more specific description of what you want to happen.
 
Back
Top