Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Passing Criteria from a form to a Query in Access OCBD linked to SQL data Expand / Collapse
Author
Message
Posted Tuesday, December 20, 2011 8:34 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, January 17, 2014 1:54 PM
Points: 157, Visits: 221
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..
Post #1224474
Posted Tuesday, January 31, 2012 12:47 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, January 8, 2013 8:48 AM
Points: 149, 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] & "#"
Post #1244718
Posted Tuesday, January 31, 2012 2:04 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 4:01 AM
Points: 1,886, Visits: 18,543

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 !
__________________________________________________________________
Post #1244762
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse