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.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-02-27 : 12:09:07
|
Saroj writes "Below sql statement to filter records from a table and it does not work while passing the date variable. I'm using the MSCAL.Calendar.7 (OLE Class : Calendar)Set rs = db.OpenRecordset("select * from increment where empno='" & Me.EmpNo & "'" & " and ChgDate=" & "#" & cboStartDate & "#")cboStartDate is a unbound date field in a access form. " |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2006-02-27 : 12:49:21
|
You need to define "does not work". Gives errors? Wrong results? If this is SQL server, then you delimit dates with a single quote, not # as you do in MS Access. But it is not clear which DB you are querying.I recommend that you use parameters, and then you never need to worry about how you should concatenate or delimit values in your SELECTS. Even DAO fully supports parameters. |
 |
|
jhermiz
3564 Posts |
Posted - 2006-03-06 : 14:05:13
|
quote: Originally posted by AskSQLTeam Saroj writes "Below sql statement to filter records from a table and it does not work while passing the date variable. I'm using the MSCAL.Calendar.7 (OLE Class : Calendar)Set rs = db.OpenRecordset("select * from increment where empno='" & Me.EmpNo & "'" & " and ChgDate=" & "#" & cboStartDate & "#")cboStartDate is a unbound date field in a access form. "
Try this:SELECT * FROM Increment WHERE EmpNO='" & Me.EmpNo.Value & "' AND ChgDate=#'" & Me.cboStartDate.Value & "'#" Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]RS Blog -- [url]http://weblogs.sqlteam.com/jhermiz[/url] |
 |
|
|
|
|