×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

DataBase Help

DataBase Help

DataBase Help

(OP)
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

RE: DataBase Help

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close