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!
  • Students Click Here

*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


Visual Basic (Microsoft) Versions 5/6 FAQ

Access Version or Conversion

Sub routine to create test records. by Michael42
Posted: 7 Feb 04

Sub addTestRecords()
    On Error GoTo ErrorHandler
    'Init Vars
    Dim oRS As Recordset
    Dim f As Integer, i As Long, k As Long, j As Integer
    Dim sTotalRecordsToAdd As String
    Dim sFieldName As String
    'Prompt and Get Total to Create
    sTotalRecordsToAdd = InputBox("Enter total records to add (1-nnnnnn).", "Total Records", "1000")
    If sTotalRecordsToAdd = "" Then
        Exit Sub
    End If
    'Add New Records
    Screen.MousePointer = vbHourglass
    Set oRS = oDB.OpenRecordset("SELECT * FROM main")
    For i = 1 To CLng(sTotalRecordsToAdd) - 1
        For f = 0 To oRS.Fields.Count - 1
            sFieldName = oRS(f).Name
            Select Case oRS(f).Type
                Case dbText
                    oRS(sFieldName) = Trim(Str(i)) & ""
                Case dbMemo
                    oRS(sFieldName) = Trim(Str(i)) & ""
                Case dbDate
                    oRS(sFieldName) = Now
            End Select
        'Help CPU Keep Up (timer loop)
        For j = 1 To 5
    'Help CPU Keep Up (timer loop)
    For j = 1 To 100
    Screen.MousePointer = vbDefault
    MsgBox Format(Str(i), "###,###,###,###") & " added.", vbInformation, "Status"
    On Error GoTo 0
    Exit Sub

    Screen.MousePointer = vbDefault
    MsgBox "Error: " & Err.Number & vbCrLf & vbCrLf & Err.Description, vbExclamation, "Error (addTestRecords)"

End Sub

Back to Visual Basic (Microsoft) Versions 5/6 FAQ Index
Back to Visual Basic (Microsoft) Versions 5/6 Forum

My Archive

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