Solved

select and dates?

Posted on 2000-04-17
8
136 Views
Last Modified: 2010-05-02
I have text box on my form
in the text box property I have format to date
when i do my select to query access database it doesn't find the record???
let say textdate.text is my textbox

do i do
select * from mydatabase where datefield=textdate.text


or do i have to do a cdate on that textbox?

the field in my access database is same as the format in my textbox

any ideas???
0
Comment
Question by:jerbell
[X]
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
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 9

Accepted Solution

by:
Ruchi earned 15 total points
ID: 2723221
Date values must be enclosed within # signs.

ie.
Select * from mydatabase where datefield = #textdate.text#

Hope this helps.

0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2723245
Date values must be enclosed within # signs.

ie.
Select * from mydatabase where datefield = #textdate.text#

Hope this helps.

0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2723255
The best way is to use the US format:

strsql = "select * from mydatabase where datefield = " & format(textdate.text, "mm/dd/yyyy")
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:detiege
ID: 2723264
I prefer doing:

SELECT * FROM Table WHERE Datafield LIKE textdate.text



Try to put your query in a buffer and execute it:

Buff = "SELECT * FROM Table WHERE DateField LIKE '" & textdate.text & "'"

conn.Execute(Buff)

But be sure that your "DateField" and your "textdate.text" are in the same format ! ! ! ! !

0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2723330
detiege,

You are new here! There is a rule that says not to post as an answer when other experts already began to answer. You don't have to lock question. The asker can always accept one of the comment as it's accepted answer because the asker has a button for it!

Also, you don't have to ensure the format when you send the date in the US format!
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2725174
emoreau:

I wholeheartedly agree that specifying the date format is the way to go. As I live and work in the USA, the mm/dd/yyyy format is no problem for me.

However, here at EE I have read several comments from people working in other nonUS locales that maintain the date default is dd/mm/yyyy. All in all.. dates still get me confused <blush>.. are you certain that mm/dd/yyyy is always the default date format regardless of locale? (I tend to believe it can be overridden through system settings.. but of that I am not sure).
0
 
LVL 1

Expert Comment

by:detiege
ID: 2725676
Excuse me to lock the question !

It's just that i'm new.

0
 

Author Comment

by:jerbell
ID: 2726416
thanks!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

738 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