Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 906
  • Last Modified:

Filtering Between dates with adodc

I am having problems with this code:
Adodc1.Recordset.Filter = "Date BETWEEN #" & dtestart & "# AND #" & dteend & "#"
I am getting an error:
Run-time error '3001':
Arguments are of the wrong type, or out of acceptable range, or are in conflict with one another.

Any help with this code would be greatly appreciated.

Thanks,
Jeff
0
fanguru1
Asked:
fanguru1
1 Solution
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
>Adodc1.Recordset.Filter = "Date BETWEEN #" & dtestart & "# AND #" & dteend & "#"
                                            ^^^

Date is a keyword that returns the date on your system clock.  If you are using this as a field name, it is likely confusing VB.  Please change your field name 'Date' to something different, and try again.

Other than that, everything else looks fine.

Hope this helps.
-Jim
0
 
fanguru1Author Commented:
I changed my database and the related links to that field to OrderDate.
This is the code I now have
Adodc1.Recordset.Filter = "OrderDate BETWEEN #" & dtestart & "# AND #" & dteend & "#"
I still have the same error.

0
 
fanguru1Author Commented:
I found this code and it worked fine:
FYI:
.Filter = "[OrderDate] >= #" & dtestart & "# AND [OrderDate] <= #" & dteend & " #"
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
leonstrykerCommented:
BTW, fanguru1 I would seroiusly suggest you get rid of ADODC and use ADO directly.

Leon
0
 
Ryan ChongCommented:
what's the data type of OrderDate? make sure it's a Date/Time data field? Also make sure the values of dtestart and dteend is valid to the field data type.
0
 
fadlounCommented:
Run-time error '3001'
error discription (Arguments are of the wrong type)
You are trying to  apply date filteration to none date-type  field

as ryancys said check orderdate type

and if this code works
.Filter = "[OrderDate] >= #" & dtestart & "# AND [OrderDate] <= #" & dteend & " #"

between MUST work also

regards
0
 
RainUKCommented:
For dtestart  and dteend, if this is based on your machines locale, then it may not be the same as the DB, e.g. dd/mm/yyyy.
Have you tried doing :

"#" & Format(dtestart,"dd/mm/yyyy HH:mm:ss") & "#"

Or the respective format ot the DB you are trying to filter.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now