Create Empty Recordset

M

Miked

Why doesn't:

Dim rst as New Recordset

work in Word VBA? I get an "invalid use of New Keyword" error.

DOA 3.6 is referenced correctly.

Urgent! Thanks!
 
T

Tony Jollans

You need to qualify the type - Word does not do it by itself for extra
referenced type libraries ..

Dim rst as New DAO.Recordset
 
M

Miked

Tony:

Thanks so much; That worked, but I think I'm doing this wrong. I
really want to populate a recordset from scratch and pull the data from
a table in a document, and then popoulate the recordset in a loop. Is
this possible, or should I be using some other type of construction?

Thanks again!

Miked
 
T

Tony Jollans

Yes, I would say you're doing it wrong! Why do you want Word data in a
Recordset? How, and in what application, are you planning to use it? In
other words, what are you ultimately trying to achieve?
 
M

Miked

Tony:

Don't know what happen to my last post. I'd basically like the data in
a more manageable and faster format; it's coming out of the MSWord
document it's currently in, in a table, and won't be modified; so I was
looking for a structure that would be faster for searches and reusable
and persistent, so I thought that a dao recordset would basically be a
min-table from a database that I coudl manipulate in word.

On the otherhand, nothing seems to be working, so I'll take any advice
I can get on this one at this poitn! Thanks!

Miked
 
M

Miked

Hi Tony:

So, I've got a table in word document that is editable and needs to be
updated. Other work in the document is going on based on this table.
I want to write code that reads the table from the doc and puts the
data into what I think should be a recordset, becuase I'm going to need
to do seek methods on the recordset in a later piece of code. The
table has to be in a doc, and cannot be in excel, access, etc. I also
want to make this recordset public and persistent so that it can be
used later on by other pieces of code that might not be run with the
piece of code that will populate it.

Thank you so much in advance for continuing to help me!

Mike
 
T

Tony Jollans

Hi Miked,

Sounds like you want database facilities on a Word Table - if that's the
case you'll probably need to use a database!

Basically you can't create a recordset like that - a recordset holds the
results of a query and you can't query a Word table. As I write that I
wonder if I'm correct - something at the back of my mind tells me it may be
possible but I don't know how to do it if it is; I'll investigate for my own
interest if nothing else. You may find the easiest thing to do is create a
temporary table (in Excel or Access) against which you can run queries.

A couple of questions:

When you say persistent, how persistent? Lifetime of currently running code,
or the document edit session, or longer?
And how public? Your Word session, your windows session, other users?
How much data do you have - how big is your (Word) table?

I know, that's an odd couple!
 
M

Miked

Tony:

Thanks again for your reponse. I've experimented with that a bit, so
given your feedback here, that's what I'll pursue. Answers to your
questiosn:

Persistence: Life of document edit session, or reload based on
source-table change; PUblic is just our word session (but I think I
figured that out with just making a different recordset public. The
table is about 250 rows.

So, do you have some code I can look at or have reference to some code
to get me going in the right direction? with loading the excel object
and then with seeking on the recordset when that's done, or maybe it
woudl just be easier to do queries in Access.

Again, thanks!

Miked
 
T

Tony Jollans

Hi Miked,

I think you are overcomplicating this. if the data really _has_ to be in
Word why not just process it in Word? 250 records is hardly a lot (how many
columns?). I'll grant Word may be a bit clumsy depending on exactly what you
want to do but I'm sure it's possible (and avoids the overhead of running a
second application).

If you're set on using a recordset then I think you should extract your Word
table data to an Access Table and run whatever queries you want. And I would
use ADO rather than DAO.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top