Re: Newbie help

Tech-Archive recommends: Fix windows errors by optimizing your registry

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


Date: Tue, 28 Dec 2004 15:12:33 -0000

Websites? www.microsoft.com and http://msdn.microsoft.com - almost all of
Microsoft's Access programming documentation since the release of Access
2000 has focussed on ADO.

As for the specific question, unless there are reasons that you didn't
mention in your post for using a recordset, it would be unnecessary and
inefficient to use a recordset for this. In the example below, the first,
commented line shows how to do it without a recordset. For completeness,
I've also included an (uncommented) example of how to do it using a
recordset.

Private Sub Command8_Click()

' CurrentProject.Connection.Execute _
' "INSERT INTO Categories (CategoryName, Description) VALUES ('" & _
' Me.CategoryName & "', '" & Me.Description & "')"

    Dim rst As ADODB.Recordset

    Set rst = New ADODB.Recordset
    With rst
        .ActiveConnection = CurrentProject.Connection
        .CursorLocation = adUseClient
        .CursorType = adOpenDynamic
        .LockType = adLockOptimistic
        .Open "SELECT CategoryName, Description FROM Categories"
        .AddNew
        .Fields("CategoryName") = Me.CategoryName
        .Fields("Description") = Me.Description
        .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.
"Dave" <dave@dave.com> wrote in message 
news:41d16f4c$0$45225$ed2e19e4@ptn-nntp-reader04.plus.net...
> Hi
>
> Any websites that will walk me thru using ado with access.  I have a form 
> with several fields.  I want to use VBA and ADO to add these fields into 
> the a recordset and then into my mdb file.
>
> Thanks
> 


Relevant Pages

  • Re: Is ADO Dead (3)?
    ... The Design of ADO ... ADO uses a single object, the Recordset, as a common representation for ... a forward-only stream of results from a database, ... where data is updated at the data source or cached locally as with the ...
    (comp.databases.ms-access)
  • Re: Is ADO Dead (3)?
    ... The Design of ADO ... ADO uses a single object, the Recordset, as a common representation for ... a forward-only stream of results from a database, ... where data is updated at the data source or cached locally as with the ...
    (comp.databases.ms-access)
  • Re: Is ADO Dead (3)?
    ... The Design of ADO ... ADO uses a single object, the Recordset, as a common representation for ... a forward-only stream of results from a database, ... where data is updated at the data source or cached locally as with the ...
    (comp.databases.ms-access)
  • Re: DAO to ADO Recordset Options
    ... DAO was really fast when dealing with Access data (faster than ADO) but was ... Recordset. ... For client-sided cursors, there is only Static cursor type regardless as ... determines how often data is fetched from the server. ...
    (microsoft.public.data.ado)
  • Re: Is ADO Dead (3)?
    ... The Design of ADO ... ADO uses a single object, the Recordset, as a common representation for ... a forward-only stream of results from a database, ... where data is updated at the data source or cached locally as with the ...
    (comp.databases.ms-access)