>I'm trying to set up a form to input a date, and run a
>query using the date as a filter. I have a text field
>on the form, not tied to any table in the data environment,
>with a control source of ldpickup, and code for a button's
>click event as shown below. The thing keeps giving me
>operand/operator type mismatches.
>
>I'm pretty sure I'm handling something wrong on the WHERE
>clause but I can't find it. I've tried single quotes,
>parentheses, DTOC(), CTOD(), and looked in a few FAQ's
>and am out of guesses. Does anyone have the syntax for this?
>
>-----------------
>LOCAL ldpickup
>CLOSE DATABASES
>OPEN .\data\tracker
>SELECT Hospital.chospnam, Masspu.ddate, Masspu.nsmall, ;
> Masspu.nlarge ;
> FROM tracker!hospital INNER JOIN tracker!masspu ;
> ON Hospital.iacctno = Masspu.iacctno ;
> WHERE Masspu.ddate = ldpickup ;
> INTO TABLE .\data\tqbill01
>
>SELECT Hospital.chospnam, Indivpu.csize, Indivpu.curn, ;
> Indivpu,ncremid, Indivpu.cownlnam ;
> FROM tracker!hospital INNER JOIN tracker!indivpu ;
> ON Hospital.iacctno = Indivpu.iacctno ;
> WHERE Indivpu.dpickup = ldpickup ;
> INTO TABLE .\data\tqbill02
>
>REPORT FORM .\reports\rpbill NOCONSOLE PREVIEW
>-----------------
>
>Thank you ...
>
>- Bob Longmire
>- Hillside IL
Bob,
Remove the controlsource (none). Set the value to {}. Change SQL to read as :
...where Indivpu.dpickup = thisform.mycontrol.value ...
You would need intermediate variable(s) like ldPickup if you intend to use it in report too. ie:
-Two textboxes on form dStart, dEnd with value {}.
gdStart = min(thisform.dStart.value, thisform.dEnd.value)
gdEnd = max(thisform.dStart.value, thisform.dEnd.value)
select ... where myDate between gdStart and gdEnd .. into cursor ..
* In report - title band
"Sales for period "+dtoc(gdStart)+" - "+dtoc(gdEnd)
Cetin