Passing Criteria from a form to a Query in Access OCBD linked to SQL data

  • I have a 2010 MSAccess database using tables linked (ODBC) to a SQL 2000 database.

    I can query dates from the linked SQL table if I use the criteria syntax <#1/6/2009#. So my question then is .. how do I pass the date criteria in this format from a form text box to the criteria for the query. The method I've tried is to put =[forms]![formname]![fieldname] in the criteria field of the query (doesn't work). I'm assuming I need to pass the required # syntax around the date criteria value to the query criteria? I've tried variations of =#[forms]![formname]![fieldname]#... but this does not work. What am I missing?

    Thanks..

  • Access automatically inserts the "#"s around a date (as long as the column you are setting your criterion off of is in date format). Because of this, you should only have to enter the date on the form (withouth the "#"s around it).

    If you want to manually force Access to read #s, you can use:

    "#" & [forms]![formname]![fieldname] & "#"

  • SELECT dbo_ORDER.DATE_ENTERED

    FROM dbo_ORDER

    WHERE dbo_ORDER.DATE_ENTERED=[Forms]![Form1]![Text1].......set format of textbox to "general date"

    ..ps in Access remember to tab out of form text box before running query

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply