title: Access 2010 VBA to put one field from a query in a variable
body: <p>In Access 2010 I need to be able to click a command button that will run a query that returns a small two field recordset.  Then put the second field in that recordset into a string variable.</p>
  
  <p>This string variable is a link to a word document on the network.  the second part of the code will then open the word document.
  Any help is GREATLY appreciated.</p>
  
  <p>I am getting the Error: "Object variable or With block variable not set" </p>
  
  <p>My Code looks like this:</p>
  
  <pre><code>    `Option Compare Database
  
  Private Sub cmdCESpec_Click()
  
  On Error GoTo Err_cmdCESpec_Click
  Dim db As Database
  Dim rs As DAO.Recordset
  Dim s As String
  Dim specSheet As String
  
  s = "SELECT p.PartNum, p.CE_SpecSheet FROM tblParts p WHERE p.PartNum = '" &amp; [Forms]![frmSpecSheet]![cboPartNum] &amp; "'" 'Chooses the correct Spec Sheet.
  Set rs = db.OpenRecordset(s)
  
  specSheet = rs.Fields("CE_SpecSheet")  'Chooses the Spec Sheet Field
  
  
  rs.Close
  
      Dim oApp As Object
  
      Set oApp = CreateObject("Word.Application")
      oApp.Visible = True
  
      With oApp
          .Documents.Open (specSheet)
      End With
  
  Exit_cmdCESpec_Click:
      Exit Sub
  
  Err_cmdCESpec_Click:
      MsgBox Err.Description
      Resume Exit_cmdCESpec_Click
  
  End Sub
  </code></pre>