PC Review


Reply
Thread Tools Rate Thread

Creating and populating a table

 
 
Becky
Guest
Posts: n/a
 
      8th Feb 2010
I would like to ask for some help. As a new programmer, I am testing some of
my subs and fuctions. To help with this, I'd like a table with 2 fields, ID
(autonumber) and strWord (these are 20 RANDOM letters long, a to z. Doubles
are OK). Rows might look like...

ID strWord
1 yhwtqggenmlportoinai
2 mlloapiqwtqmcjustepu ...etc.

Is there a fast way I can generate the table and populate it with, say, 5000
random words?

much thanks
Becky
 
Reply With Quote
 
 
 
 
kc-mass
Guest
Posts: n/a
 
      8th Feb 2010

Yes. Think of filling the data with random Alphas based on random ascii
numbersin each position.

Regards

Kevin


"Becky" <(E-Mail Removed)> wrote in message
news:757F2627-0541-4C19-90C2-(E-Mail Removed)...
>I would like to ask for some help. As a new programmer, I am testing some
>of
> my subs and fuctions. To help with this, I'd like a table with 2 fields,
> ID
> (autonumber) and strWord (these are 20 RANDOM letters long, a to z.
> Doubles
> are OK). Rows might look like...
>
> ID strWord
> 1 yhwtqggenmlportoinai
> 2 mlloapiqwtqmcjustepu ...etc.
>
> Is there a fast way I can generate the table and populate it with, say,
> 5000
> random words?
>
> much thanks
> Becky



 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      9th Feb 2010
On Mon, 8 Feb 2010 14:26:01 -0800, Becky <(E-Mail Removed)>
wrote:

>I would like to ask for some help. As a new programmer, I am testing some of
>my subs and fuctions. To help with this, I'd like a table with 2 fields, ID
>(autonumber) and strWord (these are 20 RANDOM letters long, a to z. Doubles
>are OK). Rows might look like...
>
>ID strWord
>1 yhwtqggenmlportoinai
>2 mlloapiqwtqmcjustepu ...etc.
>
>Is there a fast way I can generate the table and populate it with, say, 5000
>random words?
>
>much thanks
>Becky


sounds like fun...

Create the table with the autonumber and text field in table design view; then
run

Public Sub RandomText()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim i As Integer, j as Integer
Dim strT as String
Randomize
Set db = CurrentDb
Set rs = db.OpenRecordset("YourTableName", dbOpenDynaset)
For i = 1 to 5000
rs.AddNew
strT = ""
For j = 1 to 20
strT = strT & chr(97+fix(26*rnd()))
Next j
rs!textfield = strT
rs.Update
Next i
End Sub

Untested air code, might not get z or might include some { - tweak as needed!
--

John W. Vinson [MVP]

 
Reply With Quote
 
Becky
Guest
Posts: n/a
 
      9th Feb 2010
Excellent - thank you, John.
Becky

"John W. Vinson" wrote:

> On Mon, 8 Feb 2010 14:26:01 -0800, Becky <(E-Mail Removed)>
> wrote:
>
> >I would like to ask for some help. As a new programmer, I am testing some of
> >my subs and fuctions. To help with this, I'd like a table with 2 fields, ID
> >(autonumber) and strWord (these are 20 RANDOM letters long, a to z. Doubles
> >are OK). Rows might look like...
> >
> >ID strWord
> >1 yhwtqggenmlportoinai
> >2 mlloapiqwtqmcjustepu ...etc.
> >
> >Is there a fast way I can generate the table and populate it with, say, 5000
> >random words?
> >
> >much thanks
> >Becky

>
> sounds like fun...
>
> Create the table with the autonumber and text field in table design view; then
> run
>
> Public Sub RandomText()
> Dim db As DAO.Database
> Dim rs As DAO.Recordset
> Dim i As Integer, j as Integer
> Dim strT as String
> Randomize
> Set db = CurrentDb
> Set rs = db.OpenRecordset("YourTableName", dbOpenDynaset)
> For i = 1 to 5000
> rs.AddNew
> strT = ""
> For j = 1 to 20
> strT = strT & chr(97+fix(26*rnd()))
> Next j
> rs!textfield = strT
> rs.Update
> Next i
> End Sub
>
> Untested air code, might not get z or might include some { - tweak as needed!
> --
>
> John W. Vinson [MVP]
>
> .
>

 
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
Populating a table from another table based on a field entered Devon Microsoft Access VBA Modules 0 19th Aug 2009 10:16 PM
creating a new module and populating in with vba geskerrett@hotmail.com Microsoft Access 0 28th Sep 2006 09:58 PM
Creating and populating array from XML Aaron Microsoft Dot NET Compact Framework 3 24th Nov 2004 05:38 AM
How to go about creating a self populating cell. =?Utf-8?B?SGl6YWVk?= Microsoft Excel Misc 2 10th Nov 2004 09:27 PM
Populating a ComboBox from System report table instead of creating =?Utf-8?B?Q2h1Y2tmMjAx?= Microsoft Access VBA Modules 4 10th Nov 2004 02:08 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:50 AM.