Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, This is probably pretty si 1

Status
Not open for further replies.

twoody54

IS-IT--Management
Apr 11, 2002
150
US
Hi,

This is probably pretty simple but I am new to this. I got all this code so far and it is doing what it is supposed to.

What I am doing is taking a first name from a table of possible first names, and a last name from a table of possible last names, and inserting them into a table comprising of randomly made full names.

So far I have it able to open the record sets for the three tables. It then takes in the number of possible first names and the number of possible last names (intNumFName and intNumLName). I then am generating a random number (intFNameID and intLNameID) to be used as the ID in both the First and Last Name table which look like this...

ID FName ID LName
-------------- -------------
1 Aaron 1 Augustine
2 .... 2 .....

My question is how do I take this ID number and extract the pertaining name? I'm not sure how I would write the query in the VB coding to do it...
Once I have the pertaining Name I'm pretty sure I'll be able to get it into the table I want.
-------------------------------------------------


Dim cn As ADODB.Connection, _
rcdFirst As New ADODB.Recordset, _
rcdNames As New ADODB.Recordset, _
rcdLast as New ADODB.Recordset

Dim intFNameID, _
intNumFName, _
intLNameID, _
intNumLName As Integer

Set cn = CurrentProject.Connection
rcdFirst.Open "tblFirst", cn, adOpenKeyset, _
adLockOptimistic
rcdPlayers.Open "tblNames", cn, adOpenKeyset, _
adLockOptimistic
rcdLast.Open "tblLast",cn, adOpenKeyset, _
adlockOptimistic

intNumFName = rcdFirst.RecordCount
intNumLName = rcdLast.RecordCount

Randomize

intFNameID = Int((intNumFName * Rnd) + 1)
intLNameID = Int((intNumLName * Rnd) + 1)

Thanks in advance.

Tom
 
If you are interested in this code in DAO, let me know. DAO is generic to both '97 and '2000.


rollie@bwsys.net
 
also Tom,

Put the subject of your query in the subject line, please.

Rollie E
 
Thanks, yeah I'd like to take a look at it if you don't mind. Sorry about the subject. I realized I left it blank and hit stop but it was too late.
 
send me your email address - and what you want so I can link it to the proper sasmple mbd

rollie@bwsys.net
 
Thanks Rolliee...

I took your code and modified it to this:

intFNameID = Int((intNumFName * Rnd) + 1)
rcdFirst.Move intFNameID
Me!FName = rcdFirst!FirstName

Works like a charm now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top