String Concatination Error

  • Thread starter Thread starter Toco Hara
  • Start date Start date
T

Toco Hara

I have error in SQL expression when when my form opens. I
think problem is I have a composite key. The PK is
CustomerNum and DtOrder. I try to concatinate the PK, but
I don't think my syntax is correct. Here is my strSQL:

Dim strSQL As String, strCustID as String, strDtOrder As
String,

strCustID = Forms!frmCustomerData.CustomerID
strDtOrder = Forms!frmCustomerData.DtOrder
strSQL = "SELECT CallDt,CallTime,Disposition FROM
tblOrderHistory WHERE "
strSQL = strSQL & "CustomerID='" & strCustomerID & "' And
DtOrder='" & "#" & DtOrder & "#" & "'"
strSQL = strSQL & "' ORDER BY CallDt ASC,CallTime ASC,
Disposition ASC;"
Set rsOne = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)

Can someone show me my error? I can not concatinate the
PK because it is a composite key. Thank you

Toco
 
Toco-

I always debug.print long SQL strings like that just to see what access
sees. Often times, it's just a missed quote somewhere that throws everything
off.

Take the output from your debug and enter it as a new sql query, that will
usually tell you what is wrong if it's not obvious by looking at it.

HTH

Matt
 
It looks like you have extra quotes around DtOrder
DtOrder= #" & DtOrder & "#"

Although I always use the formats statement with dates, although I'm not
sure if it's necessary.
DtOrder= #" & Format$(DtOrder , "mm/dd/yyyy") & "#"
 
Back
Top