Consulting

Results 1 to 8 of 8

Thread: query criteria = Now()

  1. #1

    query criteria = Now()

    Dear all

    I have a table having a date field. Now I designed a form based on a query and that query has designed through above said table. I gave =Now() in date field criteria in query.
    Now I required that as the form open it matches the date field contents with current or system date and show all records fulfil the criteria. but I got null record.
    Any one have an idea? if yes then please help me to figure out that problem.

    Thanks.

    Wasim

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Wasim, I do not think that you need the "=" in the Criteria Row.
    The other problem that you may be having is that Now() has the time as well as the date.
    Try using the Date() function instead.

  3. #3
    Dear OBP

    I have tried Now() without '=' but didn't get eresult. Also Date function is not working. Would be you kindly explain the syntax of Date()?

    Thanks.

    Wasim

  4. #4
    VBAX Mentor asingh's Avatar
    Joined
    Jul 2005
    Posts
    307
    Location
    Hi,

    Are you sure..the date being compared to NOW() is actually a date..? Is it Date/Time data type in the table structures...also please paste the sql query..so we can see it..

    asingh

  5. #5
    Hi

    yes the datatype of table field is date/time and fixed to as 'short date'.
    the query is as under

    [vba]
    SELECT Main_Mail.TicklerDate, Main_Mail.Tickler_Remarks, Main_Mail.Sub
    FROM Main_Mail
    WHERE (((Main_Mail.TicklerDate)=Now()));
    [/vba]

    Thanks for an early reply.

    Wasim
    Last edited by wasim_sono; 09-13-2007 at 11:33 PM.

  6. #6
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Wasim

    You aren't using either Date or Now in that query.

    You are asking for a parameter.

  7. #7
    VBAX Regular
    Joined
    Jul 2007
    Posts
    71
    Location
    SELECT Main_Mail.TicklerDate, Main_Mail.Tickler_Remarks, Main_Mail.Sub
    FROM Main_Mail
    WHERE ((Main_Mail.TicklerDate)=Date());

  8. #8
    Hi

    The code is now corrected.

    Thanks.

    Wasim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •