title: How to execute an SQL statement in VBA using " sign to Get the ID with RecordSet Access 2013
body: <p>I am looking to execute the following code, the problem is, I need to put a String variable in the SQL which should use the "" sign inside the SQL statement. </p>
  
  <p>The problem is, I cannot use multiple "". I tried using Char to use the sign " and convert it to a String, and that's when I got lost. </p>
  
  <p>The code below shows 2 Functions. 1 To see if I get it right to print the correct SQL statement, the other is a Function to return the actual record ID which I will then use to add a new record.</p>
  
  <p>What I mainly looking to do, is use the RecordSet to get a record ID of one of the records.</p>
  
  <p>Any help would be highly appreciated.</p>
  
  <pre><code>Private Sub PrintSQLStatement_Click()
  
  Dim strSQL As String
  Dim strTmp As String
  Dim i As Integer
  
  strTmp = "UE243"
  
  strSQL = "SELECT tbl_Sales.[ID], tbl_Sales.[SaleReference] FROM tbl_Sales WHERE (((tbl_Sales.[SaleReference])= "" + strTmp + ""));"
  
  i = MsgBox(strSQL, vbOKOnly)
  
  End Sub
  
  
  
  
  
  Private Function GetSaleID(ByVal strSaleRef As String) As Integer
  
  Dim db As Database
  Dim rs As Recordset
  Dim strSQL As String
  Dim ID As Integer
  
  strSQL = "SELECT tbl_Sales.[ID], tbl_Sales.[SaleReference] FROM tbl_Sales WHERE    (((tbl_Sales.[SaleReference])= "" + strSaleRef + ""));"
  
  Set db = CurrentDb
  Set rs = db.OpenRecordset(strSQL)
  
  ID = rs.GetID
  
  rs.Close
  Set rs = Nothing
  db.Close
  
  GetSaleID = ID
  
  End Function
  </code></pre>