Hi Mike,
If I haven't misunderstood the issue, you want to get the selected value
from the calendar control in data access page, and pass the value to query
in Access database as parameter. If this is the case, we need to deal with
some scripting in the HTML page, I created a sample for your reference.
The sample receives the value from the calendar control, and it updates the
query dynamically - passing the selected date value to the query as
parameter, the query is like:
SELECT *
FROM Employees
WHERE [BirthDate]=#4/9/1992#;
In the Where clause the date is dynamically created by the selection on
data access page.
Sample
====
1. Open the northWind.mdb database.
2. Create a new query named basequery.
3. Create a new data access page, in design view, add one calendar control
and one button, save the page to disk.
4. In design view, right click the page and select Microsoft Script Editor
to open it.
5. Press ctrl+end in Microsoft Script Editor window, copy and paste the
following code; note the command button name, in this sample, its name is
Command1; ActiveXCtl0 is the calendar control.
<SCRIPT language=VBScript event=onclick for=Command1>
<!--
Dim db
Dim qdfNew
Dim strSQL
dim dbEng
dim dbpath
dbpath= MSODSC.Connection.Properties("Data Source").Value
Set dbEng = CreateObject("DAO.DBEngine.36")
'Chr(35)=#
strSQL = "SELECT * FROM Employees where [BirthDate]=" & Chr(35) &
ActiveXCtl0.Value & Chr(35)
msgbox strSQL
Set Db = dbEng.workspaces(0).opendatabase(dbpath)
db.QueryDefs("basequery").SQL = strSQL
db.Close
-->
</SCRIPT>
6. Save the changes.
7. Open the saved html file in Internet Explorer, select an valid date in
the calendar control and click the button.
8. Open the basequery in design view and we can see the date is changed.
For example, if the selected date is 12/25/2002, the query becomes:
SELECT *
FROM Employees
WHERE [BirthDate]=#12/25/2000#;
Please feel free to reply to the threads if you have any concerns or
questions.
Sincerely,
Alick Ye, MCSD
Product Support Services
Microsoft Corporation
Get Secure! - <
www.microsoft.com/security>
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Content-Class: urn:content-classes:message
| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| X-Tomcat-NG: microsoft.public.access.adp.sqlserver
|
| Hi
| Sorry about the miss post, but I am still confused.
| How do I use the date value from the calendar control and
| get it into a criteria for a query? any examples of this?
|
| Mike
|