SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


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


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

Author
Message
SQL33
SQL33
SSC-Addicted
SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)

Group: General Forum Members
Points: 486 Visits: 225
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..
guerillaunit
guerillaunit
Right there with Babe
Right there with Babe (793 reputation)Right there with Babe (793 reputation)Right there with Babe (793 reputation)Right there with Babe (793 reputation)Right there with Babe (793 reputation)Right there with Babe (793 reputation)Right there with Babe (793 reputation)Right there with Babe (793 reputation)

Group: General Forum Members
Points: 793 Visits: 329
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] & "#"
J Livingston SQL
J Livingston SQL
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12151 Visits: 37532


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

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search