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
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