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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

For Next Loop with Insert SQL Statement

Status
Not open for further replies.

ptuck

MIS
Aug 8, 2003
130
US
I am trying to insert several records into a table. The code is inserting the correct number of records, but it is entering the same data for each record. Could you guru's give me a hand with this code??

rsEntries.MoveFirst
Do Until rsEntries.EOF
For i = 1 To rsEntries("expr1")
Randomize
ranNum = Int((10000 - 1 + 1) * Rnd + 1)
strSQLInsert = "INSERT INTO table(RandomNumber, FName, LName, Phone, Email, Sponsor, Coordinator, [Month]) VALUES (" & ranNum & ", '" & strFname & "', '" & strLName & "', " & strPhone & ", '" & strEmail & "', '" & strExec & "', '" & strCoord & "', '" & strMonth & "')"
adoCon.Execute (strSQLInsert)
Next
rsEntries.MoveNext ///(I have tried to move this before the next, but does not work)
Loop
 
Forget it....I had hard coded my fields when I was testing and forgot to delete them..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top