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 » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Easiest way to create a large Access Table



 
 
Thread Tools Display Modes
  #1  
Old February 8th, 2008, 03:28 AM posted to microsoft.public.access.tablesdbdesign
BobC[_2_]
external usenet poster
 
Posts: 28
Default Easiest way to create a large Access Table

I need to create a large Access lookup table.
The table will be roughly 2500 records consisting of 12 fields.
The entries into the table can be created with simple equations and a
few nested loops. I was thinking about using VB6; but wanted to get some
opinions.
  #2  
Old February 8th, 2008, 04:18 AM posted to microsoft.public.access.tablesdbdesign
Allen Browne
external usenet poster
 
Posts: 11,706
Default Easiest way to create a large Access Table

There's an example at the end of this page of how to OpenRecordset and loop
through to create 1000 records:
http://allenbrowne.com/ser-39.html

Between the AddNew and Update, specify your fields - one per line - and
assign whatever values you want. You may be able to pull some data from
existing tables, or you could use a combination of Chr() with Rnd() to
values.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"BobC" wrote in message
...
I need to create a large Access lookup table.
The table will be roughly 2500 records consisting of 12 fields.
The entries into the table can be created with simple equations and a few
nested loops. I was thinking about using VB6; but wanted to get some
opinions.


  #3  
Old February 8th, 2008, 04:24 AM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Easiest way to create a large Access Table

On Thu, 07 Feb 2008 22:28:40 -0500, BobC wrote:

I need to create a large Access lookup table.
The table will be roughly 2500 records consisting of 12 fields.
The entries into the table can be created with simple equations and a
few nested loops. I was thinking about using VB6; but wanted to get some
opinions.


Well, VBA and VB6 are syntactically very similar. You don't say anything about
the nature of the calculations, but it would be straightforward to create a
table; open a Recordset based on it; and loop through the creation sequence
using the AddNew method to create a record, and then set the values.

Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rs = db.OpenRecordset("YourLookupTable", dbOpenDynaset)
For ... your loop expression
rs.AddNew
rs!ThisField = thisvalue
rs!ThatField = thatvalue
...
rs.Update ' write out the record
Loop
rs.Close
Set rs = Nothing

John W. Vinson [MVP]
  #4  
Old February 8th, 2008, 05:48 AM posted to microsoft.public.access.tablesdbdesign
BobC[_2_]
external usenet poster
 
Posts: 28
Default Easiest way to create a large Access Table

Thank You!

John W. Vinson wrote:
On Thu, 07 Feb 2008 22:28:40 -0500, BobC wrote:

I need to create a large Access lookup table.
The table will be roughly 2500 records consisting of 12 fields.
The entries into the table can be created with simple equations and a
few nested loops. I was thinking about using VB6; but wanted to get some
opinions.


Well, VBA and VB6 are syntactically very similar. You don't say anything about
the nature of the calculations, but it would be straightforward to create a
table; open a Recordset based on it; and loop through the creation sequence
using the AddNew method to create a record, and then set the values.

Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rs = db.OpenRecordset("YourLookupTable", dbOpenDynaset)
For ... your loop expression
rs.AddNew
rs!ThisField = thisvalue
rs!ThatField = thatvalue
...
rs.Update ' write out the record
Loop
rs.Close
Set rs = Nothing

John W. Vinson [MVP]

  #5  
Old February 8th, 2008, 05:29 PM posted to microsoft.public.access.tablesdbdesign
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Easiest way to create a large Access Table

Bob

If "...the entries ... can be created with simple equations...", why do you
need to store the calculated values?

You've explained "how" you want to do something, but not why it makes more
sense to have a "large Access lookup table" than to use a query to generate
the calculated value(s) you need "on the fly".

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP


"BobC" wrote in message
...
I need to create a large Access lookup table.
The table will be roughly 2500 records consisting of 12 fields.
The entries into the table can be created with simple equations and a few
nested loops. I was thinking about using VB6; but wanted to get some
opinions.



  #6  
Old February 11th, 2008, 04:36 AM posted to microsoft.public.access.tablesdbdesign
BobC[_2_]
external usenet poster
 
Posts: 28
Default Easiest way to create a large Access Table

I'm having a syntax??? issue with:
Set db = Data.mdb
in the test code below:

Sub AddRecords()
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim I As Integer
Set db = Data.mdb
Set rs = db.OpenRecordset("tblNewReten", dbOpenDynaset)
For I = 1 To 10
rs.AddNew
rs!HA# = 100 + I
rs!POLYR = 2007 + I
rs!PROPRET = 100000
rs!LIABRET = 100000
rs!LIABAGG = 150000

rs.Update ' write out the record
Next

John W. Vinson wrote:
On Thu, 07 Feb 2008 22:28:40 -0500, BobC wrote:

I need to create a large Access lookup table.
The table will be roughly 2500 records consisting of 12 fields.
The entries into the table can be created with simple equations and a
few nested loops. I was thinking about using VB6; but wanted to get some
opinions.


Well, VBA and VB6 are syntactically very similar. You don't say anything about
the nature of the calculations, but it would be straightforward to create a
table; open a Recordset based on it; and loop through the creation sequence
using the AddNew method to create a record, and then set the values.

Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rs = db.OpenRecordset("YourLookupTable", dbOpenDynaset)
For ... your loop expression
rs.AddNew
rs!ThisField = thisvalue
rs!ThatField = thatvalue
...
rs.Update ' write out the record
Loop
rs.Close
Set rs = Nothing

John W. Vinson [MVP]

  #7  
Old February 11th, 2008, 04:40 AM posted to microsoft.public.access.tablesdbdesign
BobC[_2_]
external usenet poster
 
Posts: 28
Default Easiest way to create a large Access Table

It is a 'lookup' table containing constants that is changed by the user;
I am just setting up the basic table.

Jeff Boyce wrote:
Bob

If "...the entries ... can be created with simple equations...", why do you
need to store the calculated values?

You've explained "how" you want to do something, but not why it makes more
sense to have a "large Access lookup table" than to use a query to generate
the calculated value(s) you need "on the fly".

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP


"BobC" wrote in message
...
I need to create a large Access lookup table.
The table will be roughly 2500 records consisting of 12 fields.
The entries into the table can be created with simple equations and a few
nested loops. I was thinking about using VB6; but wanted to get some
opinions.



  #8  
Old February 11th, 2008, 05:12 AM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Easiest way to create a large Access Table

On Sun, 10 Feb 2008 23:36:46 -0500, BobC wrote:

I'm having a syntax??? issue with:
Set db = Data.mdb
in the test code below:

Sub AddRecords()
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim I As Integer
Set db = Data.mdb


Well, I have no idea where you got that syntax but obviously it doesn't work.

If this code exists in the database named Data.mdb, just use

Set db = CurrentDb()
--
John W. Vinson [MVP]
  #9  
Old February 11th, 2008, 05:59 PM posted to microsoft.public.access.tablesdbdesign
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Easiest way to create a large Access Table

Thanks for the clarification...

Regards

Jeff Boyce
Microsoft Office/Access MVP


"BobC" wrote in message
...
It is a 'lookup' table containing constants that is changed by the user; I
am just setting up the basic table.

Jeff Boyce wrote:
Bob

If "...the entries ... can be created with simple equations...", why do
you need to store the calculated values?

You've explained "how" you want to do something, but not why it makes
more sense to have a "large Access lookup table" than to use a query to
generate the calculated value(s) you need "on the fly".

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP


"BobC" wrote in message
...
I need to create a large Access lookup table.
The table will be roughly 2500 records consisting of 12 fields.
The entries into the table can be created with simple equations and a
few nested loops. I was thinking about using VB6; but wanted to get some
opinions.



 




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 10:44 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.