Filtering Between dates with adodc

Posted on 2005-04-11
Last Modified: 2013-12-25
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.

Question by:fanguru1
    LVL 65

    Accepted Solution

    >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.

    Author Comment

    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.


    Author Comment

    I found this code and it worked fine:
    .Filter = "[OrderDate] >= #" & dtestart & "# AND [OrderDate] <= #" & dteend & " #"
    LVL 29

    Expert Comment

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

    LVL 48

    Expert Comment

    by:Ryan Chong
    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.
    LVL 5

    Expert Comment

    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

    LVL 5

    Expert Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now