Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Change Recordsource using SQL

Posted on 1998-05-05
1
160 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

856 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