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

ADO recordset update can't handle field name [Acct #] ????

Status
Not open for further replies.

UBfoolin

Programmer
Nov 29, 2001
32
US
I'm attempting to add a record to a table. My code looks like this:

recordset.AddNew

EITHER
recordset("Acct #") = '123'
OR
![Acct #] = '123'

recordset.UpdateBatch

Error msg I get is: The INSERT INTO statement contains the following unknown field name: 'Acct #'.

It appears that the single space & the pound sign character in the field name are bombing ADO. Any way around this other than renaming the field in the database (which I cannot do)? As a test, when I change the field name in the table to [Acct], the insert works perfectly, but that is NOT an alternative open to me.

MUCHO THANKSO for any assistance!

 
refer to the fields index

recordset.fields(0) if it is the first field ...
 
I believe that if you point to the field object specifically it will work. Try something like:
recordset.fields("Acct #") = '123'

If you know the field number you can also point to it that way:
recordset(3) = '123' or
recordset.fields(3) = '123'

I have run into this in the past also. Since I was also building the DB at the same time it was easy to fix the field name. Sometimes, though, that is not an option.

Hope this helps.


ttfn
dan Dan Grogan
dan@siqual.com

"Absit prudentia nil rei publicae profitur."
Without common sense you ain't gonna have nothing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top