between statement issue

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to use a between statement on a date field, and getting the 2
dates by selecting them in a form? I have tried to do this with the
following code/Query:
Query:
SELECT tblExpenses.Date, tblExpenses.Store, tblExpenses.Type,
tblExpenses.Category, tblExpenses.[Trip/Location], tblExpenses.Description,
tblCreditCards.Bank
FROM tblCreditCards INNER JOIN tblExpenses ON tblCreditCards.[Card Number] =
tblExpenses.[Credit Card]
WHERE (((tblExpenses.Date) Between [Forms]![frmstatement]![cboStartDate ]
And [Forms]![frmstatement]![cboEndDate]) AND
((tblExpenses.Type)="Reimbursements") AND ((tblCreditCards.Bank)="American
Express"));

Code on the form:
Private Sub Command8_Click()
DoCmd.OpenQuery "QryReimbursementsAmericanExpressCBO", acViewNormal, acEdit
DoCmd.Close acForm, "frmstatment"

End Sub
but I keep getting this error:
The expression On Click you entered as the event property setting produced
the follwoing error: A problem occured while Microsoft Access was
communicating with the OLE server or ActiveX Control.

Any suggestions?
 
Hi,


Try to cast the parameter, ie:



WHERE ( tblExpenses.Date BETWEEN CDate(
[Forms]![frmstatement]![cboStartDate ]) AND CDate(
[Forms]![frmstatement]![cboStartDate ] ) ) AND ...


Also note the UNUSUAL space in [cboStartDate ]. Probably a typo, remove it,
unless the control name is REALLY with a space at the end of it. When using
[ ], any character is considered, legal or not, without any interpretation
done, so it is assumed, in your case, that there is a space at the end.



Hoping it may help,
Vanderghast, Access MVP
 
Back
Top