Solved

Change Recordsource using SQL

Posted on 1998-05-05
1
159 Views
Last Modified: 2006-11-17
I would like to change my recordsource using SQL and filter my recordsouce using Date.. So, I try to create source code like this

data1.recordsource = "select * from mytable where proddate = " & maskedbox1.text

It show nothing , So, I try

data1.recordsource = " select * from mytable where proddate = " & "'" & maskedbox1.text & "'"
It show an error data type mismatch..

So, I try for declare variable as date

dim sdate as date

sdate = proddate

data1.recordsource = "select * from mytable where proddate = " & sdate

It still show nothing, even I try

data1.recordsource = "select * from mytable where proddate = " & "5/5/98"

It still show nothing.. How could I solve this problem?

PS. I use MS-Access 95 as my database and proddate is a field use Date as data type , format shortdate..

Thank you in advance.
0
Comment
Question by:Mcblake
1 Comment
 
LVL 5

Accepted Solution

by:
dirtdart earned 50 total points
ID: 1440265
When comparing literal dates within Access, the date must be surrounded by the pound sign, so that your SQL statement would end up looking like this:

data1.recordsource = "select * from mytable where proddate = #" & maskedbox1.text & "#"

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question