I'm trying to create a function that will search an Access Database to see if a record already exists or not.

I am having problems with my select statement with regards to the where part of it.


Here's what i have so far:

VB Code:
  1. Option Explicit
  2. Private prvCNNBatchHeader As New ADODB.Connection
  3.  
  4.  
  5. Private Function FindExistingRecord(strTransactionType As String, strBatchNumber As String) As Boolean
  6.  
  7. Dim rsBatchHeader As New ADODB.Recordset
  8.  
  9.  
  10. rsBatchHeader.Open "Select * From BatchHeader Where BatchHeader.TransactionType = strTransactionType and BatchHeader.BatchNumber = strBatchNumber", prvCNNBatchHeader, adOpenDynamic, adLockOptimistic
  11.  
  12. end Function

I am getting an error stating: [Microsoft][ODBC Microsoft Access Driver] Too Few Parameters. Expected 2.

Where i run the select part without the where clause, it seems to work fine, but not with the Where.

Hope someone can help
thanks