title: VBA Access - Having trouble inserting multiple records into a table
body: <p>I am new to VBA, so I'm having trouble understanding what is going on. I am trying to fill a table with 50,000 records with the following code:</p>
  
  <pre><code>Sub arrayData()
  Dim custnames() As Variant
  Dim num As Long, dbs As Database, InsertRecord As String
  Dim CusSalaryId As Long, num1 As Long, EmpId As Long
  Dim EmpSalary As String
  Set dbs = CurrentDb()
  EmpId = 0
  CustSalaryId = 0
  For num1 = 0 To 50000
  CustSalaryId = CustSalaryId + 1
  EmpId = EmpId + 1
  custnames = Array("$1000", "$500", "$300", "$600")
  
  
  
  num = Int((UBound(custnames) - LBound(custnames) + 1) * Rnd + LBound(custnames))
  EmpSalary= custnames(num)
  
  InsertRecord = "insert into SALARY (SalaryID, NetSalary, EmployeeID) 
  values (" &amp; "'" &amp; CustSalaryId &amp; "'" &amp; "," &amp; "'" &amp; EmpSalary &amp; "'" &amp; "," &amp; "'" &amp; EmpId &amp; "'" &amp; ")"
  
  dbs.Execute InsertRecord
  Debug.Print SalaryId; EmpSalary; EmpId;
  
  Next
  
  End Sub
  </code></pre>
  
  <p>When I run it, I get only 2 records:
  <a href="https://i.stack.imgur.com/djWcZ.png" rel="nofollow noreferrer">Salary Table Output</a></p>