title: MS access SELECT INTO in vba
body: <p>I'm having some issues with some functionality of my application. There is a particular instance where I have an instance of a 'pending class' on a form for an administrator to review. The form is populated with students associated with this pending class. After their grades are finished, I have a button at the footer that will delete this class from my 'pending' table and add the grades to all of the students. This works.
  However, I want to essentially copy this pending class, which just has the class name, date, and teacher to a completed class table before it's deleted from pending. Since no data about this class other than the primary key(class number) persists throughout this form, I can't populate the other fields(class name, date) of the row into my completed class table.</p>
  
  <p>I am trying a "SELECT INTO" operation in VBA to get these values. It's going like this:</p>
  
  <pre><code>   dim cname as String
     dim classdate as Date
     dim pid as integer
     dim teacher as String
     dim qry as String
  
      pid = [Forms]![frmClasses]![txtID]
  
     qry = "Select className INTO cname FROM tblPending WHERE tblPending.id = " &amp; " ' " &amp; pid &amp; " ' " &amp; ";"
  
     db.execute qry
     debug.print qry
     debug.print cname   
  </code></pre>
  
  <p>From here, I do the same operations for each other variable, build my INSERT query, and execute it. The problem is-- my select into's are not working. Debug.print shows that the local variables were never initialized from the SELECT INTO statement. Any thoughts?</p>