A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

newbie needs examples of creating a recordset and inserting datausing it in Access 2007?



 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old May 31st, 2010, 03:28 AM posted to comp.databases.ms-access,microsoft.public.access
r
external usenet poster
 
Posts: 5
Default newbie needs examples of creating a recordset and inserting datausing it in Access 2007?

I have created a Access 2007 database, Test.mdb, created a table called
"mytest" and created required fields in it. Now, using VBA(Visual Basic
for Applications) I want to insert data into it using a Recordset from a
Word document.

Can anyone please point me to a proper link where there is an example of
how data is inserted using a Recordset into a Access 2007 table?

I created one using resources on Web, but it is not correct.

Sub TestRecordsetexample

Dim cnn1 As ADODB.Connection
Set cnn1 = CurrentProject.Connection
Dim myRecordSet As New ADODB.Recordset
myRecordSet.ActiveConnection = cnn1

myRecordSet.Open "[Test]"

Dim myRecordSet As New ADODB.Recordset
myRecordSet.ActiveConnection = cnn1

myRecordSet.Open “SELECT * FROM mytest”

MsgBox myRecordSet.fields(0).value

myRecordSet.Close
cnn1.Close

End Sub

I get a compile time error for "Dim cnn1 As ADODB.Connection" as "User
defined Type not defined"


I want to choose Tools-References from the VBA Editor menu bar, but
References is disabled and I cannot choose it.

I guess I have to set up the connection from Word 2007(where the above
code is present as a Macro) to Access 2007(where the database is) which
I have not done.

Any advice would be welcome on how to fix the above error and some
examples of using Recordsets with Access 2007.

Thanks
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:55 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.