PC Review


Reply
Thread Tools Rate Thread

Add records to tdfNew as TableDef

 
 
=?Utf-8?B?UGVuZHJhZ29u?=
Guest
Posts: n/a
 
      20th Feb 2007
Access03/WinXP

I've looked through many samples and searches and *think* I have figured out
how to programmatically create a temporary table and create the necessary
fields, but I have yet to see how to add data to that table from a recordset.

If I have rs as a recordset with at least ContactID, DateCanceled as
selected fields, and have created tdfNew, appended to the database, and added
the fields ContactID and DateCanceled, how do I now add records to that table.

Typically, I have manually created the temporary table in the database
window in design view and then used a Do While Not rs.EOF loop to add records.

Do While Not rs.EOF
with tdfNew
.AddNew

The problem is that as soon as I type the period where the AddNew should be
inserted, AddNew is not one of the options.

Can anyone give me an example, or point me to a resource, where there is a
sample to programmatically create a table, add fields, and then populate said
table? Much appreciated!
 
Reply With Quote
 
 
 
 
Alex Dybenko
Guest
Posts: n/a
 
      20th Feb 2007
Hi,
how did you declare rs?
if this is recordset, ADO or DAO, addnew should work. do you get an error
when you run your code?

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

"Pendragon" <(E-Mail Removed)> wrote in message
news:73C9DE08-2C4E-40C3-922E-(E-Mail Removed)...
> Access03/WinXP
>
> I've looked through many samples and searches and *think* I have figured
> out
> how to programmatically create a temporary table and create the necessary
> fields, but I have yet to see how to add data to that table from a
> recordset.
>
> If I have rs as a recordset with at least ContactID, DateCanceled as
> selected fields, and have created tdfNew, appended to the database, and
> added
> the fields ContactID and DateCanceled, how do I now add records to that
> table.
>
> Typically, I have manually created the temporary table in the database
> window in design view and then used a Do While Not rs.EOF loop to add
> records.
>
> Do While Not rs.EOF
> with tdfNew
> .AddNew
>
> The problem is that as soon as I type the period where the AddNew should
> be
> inserted, AddNew is not one of the options.
>
> Can anyone give me an example, or point me to a resource, where there is a
> sample to programmatically create a table, add fields, and then populate
> said
> table? Much appreciated!


 
Reply With Quote
 
=?Utf-8?B?Sm9uIExleQ==?=
Guest
Posts: n/a
 
      20th Feb 2007
Hi there,

You need to open a recordset on your new table to add records to it.

Set rsTarget = db.OpenRecordset("NewTableName")
Do While Not rs.EOF
With rsTarget
.AddNew
!ContactID = rs!ContactID
!DateCanceled = rs!DateCanceled
.Update
End With
rs.MoveNext
Loop

Jon.

"Pendragon" wrote:

> Access03/WinXP
>
> I've looked through many samples and searches and *think* I have figured out
> how to programmatically create a temporary table and create the necessary
> fields, but I have yet to see how to add data to that table from a recordset.
>
> If I have rs as a recordset with at least ContactID, DateCanceled as
> selected fields, and have created tdfNew, appended to the database, and added
> the fields ContactID and DateCanceled, how do I now add records to that table.
>
> Typically, I have manually created the temporary table in the database
> window in design view and then used a Do While Not rs.EOF loop to add records.
>
> Do While Not rs.EOF
> with tdfNew
> .AddNew
>
> The problem is that as soon as I type the period where the AddNew should be
> inserted, AddNew is not one of the options.
>
> Can anyone give me an example, or point me to a resource, where there is a
> sample to programmatically create a table, add fields, and then populate said
> table? Much appreciated!

 
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
Creating fields in tdfNew =?Utf-8?B?UGVuZHJhZ29u?= Microsoft Access VBA Modules 3 6th Nov 2007 01:36 AM
Using TableDef Bill Microsoft Access Form Coding 6 6th Jan 2007 04:32 AM
TableDef =?Utf-8?B?RHdpZ2h0?= Microsoft Access Forms 3 4th May 2006 11:06 PM
TableDef Lee T. Microsoft Access 1 17th Mar 2004 05:17 AM
Set a tabledef = Nothing soncken Microsoft Access 0 15th Sep 2003 12:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:26 PM.