title: Dlookup VBA code with 2 criteria
body: <p>I have an MS Access form with a project_ID field combo box and several other fields. Once the user selects the project_ID field, majority of the subsequent fields on the form are automatically populated. I am trying to add a field on the form that displays information not only based on the project_ID but also a Trans_ID. The catch is that I want the Trans_ID to be a text box on the form, in which the user can simply type in the Trans_ID and in another text box, the Error_DTL_1 field is displayed. This is the VBA code that I have generated so far:</p>
  
  <pre><code>Private Sub cboProjectID_Change()
  
  Dim VarComboKey As Integer 
  Dim VarObjective As Variant 
  Dim VarStartDate As Variant 
  Dim VarEndDate As Variant 
  Dim VarRiskCategory As Variant 
  Dim VarTarDatSet As Variant
  
  Dim VarErrorCount As Variant 
  Dim VarErrorCode As Variant
  
  Dim VarErrorDTL As Variant
  
  VarComboKey = Me.cboProjectID.Value
  
  VarObjective = DLookup("[Objective]", "[Project_HDR_T]", "[Project_ID]= " &amp; VarComboKey) 
  Me.txtObjective = VarObjective
  
  VarStartDate = DLookup("[Start_Date]", "[Project_HDR_T]", "[Project_ID] = " &amp; VarComboKey) 
  Me.txtStartDate = VarStartDate
  
  VarEndDate = DLookup("[End_Date]", "[Project_HDR_T]", "[Project_ID] = " &amp; VarComboKey) 
  Me.txtEndDate = VarEndDate
  
  VarRiskCategory = DLookup("[Risk_Category]", "[Project_HDR_T]", "[Project_ID] = " &amp; VarComboKey) 
  Me.txtRiskCategory = VarRiskCategory
  
  VartxtTarDatSet = DLookup("[Targeted_Dataset]", "[Project_Targeted_Dataset]", "[Project_ID] = " &amp; VarComboKey)
  Me.txtTarDatSet = VartxtTarDatSet
  
  VarErrorCount = DLookup("[Count_Error_Codes]", "[Project_Error_Final]", "[project_ID] = " &amp; VarComboKey)
  Me.txtErrorCount = VarErrorCount
  
  VarErrorCode = DLookup("[ErrorCode]", "[Project_Error_Final]", "[project_ID] = " &amp; VarComboKey) 
  Me.txtErrorCode = VarErrorCode
  
  VarErrorDTL = DLookup("[Error_DTL_1]", "[Project_DTA_REV_T]", "[project_ID] = " &amp; VarComboKey And "[Trans_ID] = forms![Quality Risk Assessment]!me.stTransID") 
  Me.txtErrorDTL = VarErrorDTL
  
  End Sub  
  </code></pre>
  
  <p>The two lines before the "End Sub" are my attempt at attacking this code. But every time i make a selection in the Project_ID combo box on the form, i get an error "Run time Error 13, Type Mismatch".</p>
  
  <p>Can anyone help?</p>