Re: Newbie help
From: Brendan Reynolds (brenreyn)
Date: 12/28/04
- Next message: pmud: "Primary key for SQL database? Is UNIQUE IDENTIFIER ok?"
- Previous message: Gérard Leclercq: "Re: Newbie help"
- In reply to: Dave: "Newbie help"
- Messages sorted by: [ date ] [ thread ]
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 >
- Next message: pmud: "Primary key for SQL database? Is UNIQUE IDENTIFIER ok?"
- Previous message: Gérard Leclercq: "Re: Newbie help"
- In reply to: Dave: "Newbie help"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|