Solved

select and dates?

Posted on 2000-04-17
8
134 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
  • 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

777 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