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

DataBase Help

Status
Not open for further replies.

Travis33

Programmer
Nov 20, 2000
31
0
0
US
I have a database with one table and one form. I am building it to test the search feature when you have 20,000+
records. I have five fields(auto number,number,date,time,string) I have a command button that I want to be able to click and it writes 20 new records to the table. I want them to be auto generated so i don't have to type anything in. Can someone please help me. Thank You Travis
 
I'm not sure exactly what you want but try this code out for you OnClick event procedure for your command button. I will call this command buttom "cmdExecute".

Private Sub cmdExecute_Click()
Dim rstTemp as Recordset, x as Integer, i as integer
Dim strRandString as string

Set rstTemp = Currentdb.OpenRecordset("YourTableName")

For I = 1 to 20
'This line will create a random 5 character string
For x = 1 to 5
strRandString = strRandString & Chr(Int((90 * Rnd)+65))
Next x

With rstTemp
.AddNew
'This will get a random # between 1 and 1000
.fields("Number") = Int((1000 * Rnd) + 1)
.fields("Date") = Date
.fields("Time") = Now
.fields("String") = strRandString
.update
end with
strRandString = ""
Next I

Set rstTemp = Nothing
End Sub

Hope it helps. If you have any other questions let me know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top