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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating fields

Status
Not open for further replies.

shahina

Programmer
Aug 19, 2003
47
IN
Hello...

i want to update two fields of a table when user tries to change the code from the grid..i have given in the leavecell event of grid to update the fields..but i am getting the error such as recordset not opened..
what i have given is, recordset.open"UPDATE mytablename SET fieldname='value' AND trim(mid(fieldname,4,6))='value'",myconnection
it is coming that the "operation is not allowed when the object is closed"..how to do? please help me...
thanx in advance..
 
There are a couple of things:

*Have you already openned the connection to the database, as this line only opens the recordset and returns the rs to you.

*Place the trim statemant outside the "", and use & to concatenate the string:

recordset.open"UPDATE mytablename SET " & _
fieldname = 'value' AND " & _
trim(mid(fieldname,4,6)) & " = 'value'",myconnection

Hope this helps

BB
 
2 things to note:

1. Using Update on a table without a Where clause will cause all records to have 'fieldname' set to the same 'value'

2. I don't see what the AND is trying to achieve. If you're doing an update on 2 fields then the syntax is:
[tt]
Update myTablename Set field1 = 'value', myotherfield = 'othervalue' WHERE myCriterionField = 'criterion'[/tt]

If you are after something else please clarify

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top