Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 SQL date query in access

Author  Topic 

surfingdanno
Starting Member

2 Posts

Posted - 2005-07-12 : 06:00:04
Hi i Am having difficulty with this code, can anyone help.
I get the error: ADO Error: Line 5: Incorrect Syntax near '!'

around this area of the code:
set @mydate = forms!test!field0

How can I say : date - variable, use varible date then run the report?

any help would be appreciated.(code fields have been modified as it is sensitive data)

Alter Procedure [temp1]
As
declare @mydate date
set @mydate = forms!test!field0
--date field in test form
Truncate Table
temp1
Insert Into
Temp1
Select
date1
from
table1
Where
date1 > @mydate

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-12 : 06:30:47
I think you need to pass that date as parameter to the procedure
Alter Procedure [temp1]
(@date datetime)
As
Truncate Table temp1
Insert Into Temp1 Select date1 from table1 Where date1 > @date


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

surfingdanno
Starting Member

2 Posts

Posted - 2005-07-12 : 07:21:17
Cheers for that. The code worked fine.

One other question. At present the value is entered via a Parameter box. Do you know how to substitute this so I can enter the value into a text box on a form?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-12 : 07:43:22
Call this procedure by passing textbox value to it
Something like

con.execute("temp1 #" & textbox.text & "#")

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -