Re: Access VBA update recordset error

From: Brendan Reynolds (brenreyn)
Date: 10/28/04


Date: Thu, 28 Oct 2004 18:00:26 +0100

I don't see anything obviously wrong with the example you posted, and the
test code below works for me. I prefer something like rst.Fields("Field
Name") myself, as it is a little more explicit, but ![Field Name] should
work, too. What error are you seeing?

Public Sub TestUpdate()

    Dim rst As ADODB.Recordset
    Set rst = New ADODB.Recordset
    With rst
        .ActiveConnection = CurrentProject.Connection
        .CursorLocation = adUseClient
        .CursorType = adOpenKeyset
        .LockType = adLockOptimistic
        .Open "SELECT * FROM tblTest"
        .AddNew
        ![Field Name With Spaces] = "Some Text"
        .Update
        .Close
    End With

End Sub

-- 
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com
The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
"cityofgp" <cityofgp@discussions.microsoft.com> wrote in message 
news:FB8B3D87-5187-44A8-A150-4609ED660939@microsoft.com...
> Using ADODB.recordset and connection, I can successfully update records 
> using:
>
> rs![field1] = "blah"
> rs.update
>
> However, when I have a field name with a space as follows:
>
> rs![field 1] = "blah"
> rs.update
>
> I get a syntax error message.
> How can I update fields that have spaces in the field name? What syntax do 
> I
> use?
>
> TIA.
> 


Relevant Pages

  • Re: ADO/ALTER TABLE problem
    ... Public Sub AddCols() ... > But I checked the datatype using... ... >> me to use a real e-mail address in public newsgroups. ... >> GlobalSign digital certificate is a forgery and should be deleted without ...
    (microsoft.public.data.ado)
  • Re: Open Access From via Visual Basic
    ... GlobalSign digital certificate is a forgery and should be deleted without ... > "Brendan Reynolds" <brenreyn at indigo dot ie> wrote in message ... >> me to use a real e-mail address in public newsgroups. ... >>> I'd like to open my Access form, on a particular Invoice. ...
    (microsoft.public.access.forms)
  • Re: Skip Text Box LostFocus when Button is Pressed??
    ... > "Brendan Reynolds" <brenreyn at indigo dot ie> wrote in message ... >> me to use a real e-mail address in public newsgroups. ... >> GlobalSign digital certificate is a forgery and should be deleted without ... >>> issue it's event without calling the LostFocus event of the Text Box. ...
    (microsoft.public.access.formscoding)
  • Re: Access Viewer
    ... GlobalSign digital certificate is a forgery and should be deleted without ... "Jeff Conrad" wrote in message ... > "Brendan Reynolds" wrote in message ... >> me to use a real e-mail address in public newsgroups. ...
    (microsoft.public.access.forms)
  • Re: Access 97 to 2000/XP very very slow
    ... I have no idea, Alex. ... >> me to use a real e-mail address in public newsgroups. ... >> GlobalSign digital certificate is a forgery and should be deleted without ... >>> error" produced during the conversion process. ...
    (microsoft.public.access.conversion)