PC Review


Reply
Thread Tools Rate Thread

append row to table?

 
 
Keith G Hicks
Guest
Posts: n/a
 
      19th Sep 2007
I have a dot file that contains a table. I need to populate that table via
VBA from MS Access. I've done this sort of things many times but what I need
to do here appears to be different than what I'm used to.

There is a header row in the table. Then I have 1 detail row below that. I
presently have bookmarks in each cell of that row. The problem is that the
code I'm writing will need to add sevearl more detail rows the number of
which can vary from customer to customer.

The first question is how can I "append" a new row in code so that the new
row goes to the end instead of "inserting" it above the current row?

The second question is what is the best way to get the data into the other
rows since I can only have one set of bookmarks for the first row? Should I
abandon bookmarks altogether and just use "TAB" in code to get to where I
need to be on the form before posting the data to it?


Thank you,

Keith


 
Reply With Quote
 
 
 
 
Jay Freedman
Guest
Posts: n/a
 
      19th Sep 2007
The statement

myTable.Rows.Add

adds one new row at the end of the table (I assume you've assigned the Table
object named myTable to point to the correct table in the document). The
..Add method can take an optional parameter containing the index of an
existing row, and the new row would be added before that existing row. Omit
the parameter completely to put the new row at the end.

Each cell of the table is independently addressable without bookmarks. As an
example, if you want to put text into the second cell of the last row of the
table, you can do something like this:

Dim lastRow As Long
...
myTable.Rows.Add
lastRow = myTable.Rows.Count
myTable.Cell(lastRow, 2).Range.Text = "some text"

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

Keith G Hicks wrote:
> I have a dot file that contains a table. I need to populate that
> table via VBA from MS Access. I've done this sort of things many
> times but what I need to do here appears to be different than what
> I'm used to.
>
> There is a header row in the table. Then I have 1 detail row below
> that. I presently have bookmarks in each cell of that row. The
> problem is that the code I'm writing will need to add sevearl more
> detail rows the number of which can vary from customer to customer.
>
> The first question is how can I "append" a new row in code so that
> the new row goes to the end instead of "inserting" it above the
> current row?
>
> The second question is what is the best way to get the data into the
> other rows since I can only have one set of bookmarks for the first
> row? Should I abandon bookmarks altogether and just use "TAB" in code
> to get to where I need to be on the form before posting the data to
> it?
>
>
> Thank you,
>
> Keith



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Append query - Append to table with Autonumber field Boon Microsoft Access Queries 2 29th Jun 2009 06:23 PM
INSERT SQL to append recs frm another Table, NULL DATE append 30/1 accesshar Microsoft Access VBA Modules 2 14th Jan 2008 02:00 PM
Using append/update queries to transfer record data from one Table to another Table DiDi Microsoft Access Queries 1 4th Jan 2007 04:12 PM
import and append excel file to main table and sub table socasteel21 via AccessMonster.com Microsoft Access Queries 9 26th Jun 2006 03:32 PM
Paste Append - I want to make a table of records that don't append =?Utf-8?B?Q0o=?= Microsoft Access Queries 1 5th Jul 2005 06:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:57 PM.