in data environment i write

Select * from item where date and date between DTFr.value and DTTo.vlaue

In button I write

Load DataEnvironment1
    With DataEnvironment1
    If .rscmborder.State <> 0 Then .rscmborder.Close
     .cmborder Format(DTFr.Value, "dd/mm/yyyy"), Format(DTTo.Value, "dd/mm/yyyy")
     End With
     drorder.Show

but the report show all item from 1st date. it not show the range of date. (What I selected)

Dani AI

Generated

Most likely causes: the SQL/filter in the Data Environment is not getting two proper Date-type parameters, the field name date is colliding with a SQL keyword, or the code is passing formatted text instead of Date values. BETWEEN is inclusive, so if parameters are passed incorrectly (or one is missing/Null) the result set can look wrong.

Fix checklist and a minimal example

  • In the Data Environment command use parameter placeholders (two parameters) and set each parameter's type to a Date/DBDate in the DE designer.
  • Do not pass formatted strings. Assign the DateTimePicker values directly to the parameters so ADO/DE binds real Date values.
  • If the column is named date, either rename it or bracket it (for example, use [date] in the SQL) because date is a reserved word in many engines.

Example of assigning parameters from code (replace cmdItems with your command name):

With DataEnvironment1.cmdItems
  .Parameters(0).Value = DTFr.Value
  .Parameters(1).Value = DTTo.Value
End With

DataReport1.Show

Troubleshooting tips

  • Verify the command in the Data Environment actually has two parameters in the right order. Parameter order matters for unnamed placeholders.
  • Confirm the table column is a Date/Time type and that DTFr.Value <= DTTo.Value; swap if necessary.
  • Test the same BETWEEN filter directly in the database (using literal dates or the DB’s required date-literal syntax) to rule out report-side issues.
  • If still no filter, open the DE designer and try previewing the command after manually supplying sample Date parameters—this quickly shows whether the DE query itself is correct.

was correct about using parameters; ’s note on BETWEEN semantics is helpful. , check parameter types and stop converting the pickers to formatted strings—pass the Date values directly.

Recommended Answers

All 3 Replies

Hi,

In D.Env, u have to write:
Select * from item where date and date between ? and ?

Then select appropriate type in parameter list..

Regards
Veena

ya i did it.

Abu, have a look at THIS link. it will give you the options you need.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.