Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date syntax in RecordSelectionFormula

Status
Not open for further replies.

msay

Programmer
Aug 17, 2001
56
US
I have a user pick a date in VB6 and try to pass it to a report with the following code:
Report.RecordSelectionFormula = "{ado.startWK} = #" & stDate & "#"

the variable 'stDate' is a date.
I get an error. Any ideas welcome. Thanks...
 
Sorry about that. My error is "A number, currency amount, boolean or string is expected here." The code hangs at Report.RecordSelectionFormula = "{ado.startWK} = #" & stDate & "#"

Thanks...
 
Curious because ado.startWk is formated as Date/Time field in my access database.
The following code comes just before my Report.RecordSelectionFormula.

Dim stDate As Date
stDate = CDate(SSDateCombo1.Text)
Report.RecordSelectionFormula = "{ado.startWK} = #" & stDate & "#"
'===================

Report.RecordSelectionFormula = "{ado.startWK} = #3/3/2003#" is what is being output.
 
It looks as though you convert it to a date, and then treat it as a string, leave it as text and pass that:

Dim stDate As Text
stDate = SSDateCombo1.Text
Report.RecordSelectionFormula = "{ado.startWK} = #" & stDate & "#"

-k
 
chelseatech,
I'm not quite sure what you mean "Convert your date to Date(2003,3,31)" Before the Report.RecordSelectionFormula?
 
He means in lieu of:

#" & stDate & "#"

use:

"{ado.startWK} = cdate(" & stDate & ")"

-k
 
This is the code I finnally got to work...

Dim stDate As String
stDate = Format(SSDateCombo1.Text, "yyyy,mm,dd")
Report.RecordSelectionFormula = "{ado.startWK} = date(" & stDate & ")"

Thanks to all for the help!
MS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top