472,810 Members | 4,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,810 software developers and data experts.

test for empty values in date formatted text boxes

Hi,

I really hope someone can help me because I've already spend 2 days on
this problem and I'm not getting anywhere. I think the problem is that
I don't really understand how text boxes store 'empty' values. I'm
trying tot do the following.

I have a continous sub form that lists transactions. On the top level
form I have some text boxes to let the user specify the transactions
between which dates should be listed. To do this I have two text boxes
with a date format: one for the from date (ctlFrom) and ane for the to
date (ctlTo). Whenever one of the two boxes are updated I requery the
subform. When the boxes are empty I want the query to return all
transactions. The query I use for the subform is:

SELECT account, date, amount, specification FROM tblTransactions
WHERE
((date > Forms!MainForm!ctlFrom) OR (Forms!MainForm!ctlFrom=""))
AND
((date > Forms!MainForm!ctlTo) OR (Forms!MainForm!ctlTo=""));

This works when the text boxes (ctlFrom and ctlTo) contain date values
but not when the text boxes are empty. I've also tried to use NULL
instead of the empty string but the results are the same. Does anyone
know what value I should use to test for an empty box, or perhaps
there are better approaches to what I'm doing.

Thanks, Gertjan
Nov 12 '05 #1
7 8581
Gertjan van Heijst wrote:
Hi,

I really hope someone can help me because I've already spend 2 days on
this problem and I'm not getting anywhere. I think the problem is that
I don't really understand how text boxes store 'empty' values. I'm
trying tot do the following.

I have a continous sub form that lists transactions. On the top level
form I have some text boxes to let the user specify the transactions
between which dates should be listed. To do this I have two text boxes
with a date format: one for the from date (ctlFrom) and ane for the to
date (ctlTo). Whenever one of the two boxes are updated I requery the
subform. When the boxes are empty I want the query to return all
transactions. The query I use for the subform is:

SELECT account, date, amount, specification FROM tblTransactions
WHERE
((date > Forms!MainForm!ctlFrom) OR (Forms!MainForm!ctlFrom=""))
AND
((date > Forms!MainForm!ctlTo) OR (Forms!MainForm!ctlTo=""));

This works when the text boxes (ctlFrom and ctlTo) contain date values
but not when the text boxes are empty. I've also tried to use NULL
instead of the empty string but the results are the same. Does anyone
know what value I should use to test for an empty box, or perhaps
there are better approaches to what I'm doing.

Thanks, Gertjan

Just before you requery you could test for the values of the textboxes. I
presume this is in the after_update event.

e.g
If isnull(me.ctlFrom.value) Then
'use different query that selects all records
Else
'use query you specified above
End if

hth
Martin
Nov 12 '05 #2
shouldn't it be date <= Forms!MainForm!ctlTo?

"Gertjan van Heijst" <gv******@xs4all.nl> wrote in message
news:55*************************@posting.google.co m...
Hi,

I really hope someone can help me because I've already spend 2 days on
this problem and I'm not getting anywhere. I think the problem is that
I don't really understand how text boxes store 'empty' values. I'm
trying tot do the following.

I have a continous sub form that lists transactions. On the top level
form I have some text boxes to let the user specify the transactions
between which dates should be listed. To do this I have two text boxes
with a date format: one for the from date (ctlFrom) and ane for the to
date (ctlTo). Whenever one of the two boxes are updated I requery the
subform. When the boxes are empty I want the query to return all
transactions. The query I use for the subform is:

SELECT account, date, amount, specification FROM tblTransactions
WHERE
((date > Forms!MainForm!ctlFrom) OR (Forms!MainForm!ctlFrom=""))
AND
((date > Forms!MainForm!ctlTo) OR (Forms!MainForm!ctlTo=""));

This works when the text boxes (ctlFrom and ctlTo) contain date values
but not when the text boxes are empty. I've also tried to use NULL
instead of the empty string but the results are the same. Does anyone
know what value I should use to test for an empty box, or perhaps
there are better approaches to what I'm doing.

Thanks, Gertjan

Nov 12 '05 #3
Test ctlFrom and ctlTo prior to constructing your query, if they are null,
assign them values that will include all the data in your table, IE:
ctlFrom = #1/1/1900#
ctlTo = Now()

"Gertjan van Heijst" <gv******@xs4all.nl> wrote in message
news:55*************************@posting.google.co m...
Hi,

I really hope someone can help me because I've already spend 2 days on
this problem and I'm not getting anywhere. I think the problem is that
I don't really understand how text boxes store 'empty' values. I'm
trying tot do the following.

I have a continous sub form that lists transactions. On the top level
form I have some text boxes to let the user specify the transactions
between which dates should be listed. To do this I have two text boxes
with a date format: one for the from date (ctlFrom) and ane for the to
date (ctlTo). Whenever one of the two boxes are updated I requery the
subform. When the boxes are empty I want the query to return all
transactions. The query I use for the subform is:

SELECT account, date, amount, specification FROM tblTransactions
WHERE
((date > Forms!MainForm!ctlFrom) OR (Forms!MainForm!ctlFrom=""))
AND
((date > Forms!MainForm!ctlTo) OR (Forms!MainForm!ctlTo=""));

This works when the text boxes (ctlFrom and ctlTo) contain date values
but not when the text boxes are empty. I've also tried to use NULL
instead of the empty string but the results are the same. Does anyone
know what value I should use to test for an empty box, or perhaps
there are better approaches to what I'm doing.

Thanks, Gertjan

Nov 12 '05 #4
"Gertjan van Heijst" <gv******@xs4all.nl> wrote in message
news:55*************************@posting.google.co m...

<snip>

SELECT account, date, amount, specification FROM tblTransactions
WHERE
((date > Forms!MainForm!ctlFrom) OR (Forms!MainForm!ctlFrom=""))
AND
((date > Forms!MainForm!ctlTo) OR (Forms!MainForm!ctlTo=""));

This will work:

between iif(isnull(Forms!MainForm!ctlFrom),[date],Forms!MainForm!ctlFrom)
AND
iif(isnull(Forms!MainForm!ctlTo),[date],Forms!MainForm!ctlTo)

Also, I'd advise against a field named date, since there is a function with
the same name. It could cause confusion or errors at some point. Use
dateVal or somesuch thing instead.

HTH
Yon-Paul

Thanks, Gertjan

Nov 12 '05 #5
Or possibly

If Len(Trim$(myTextBox.Value & "")) = 0 Then

to also catch those cases where the textbox contains one or more spaces, and
nothing else.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
"Chuck Grimsby" <c.*******@worldnet.att.net.invalid> wrote in message
news:g9********************************@4ax.com...

The *BEST* way to look for either empty or null textbox values
(regardless if it's a date, number or text) is to use the syntax:

if len(myTextBox.Value & "") = 0 then

The & "" part above supplies a length of 0 to a Null (or empty) value,
but does nothing if it has anything in it.

You can also use this when you're going through recordsets.

On 30 Aug 2003 05:16:59 -0700, gv******@xs4all.nl (Gertjan van Heijst)
wrote:
I really hope someone can help me because I've already spend 2 days on
this problem and I'm not getting anywhere. I think the problem is that
I don't really understand how text boxes store 'empty' values. I'm
trying tot do the following.

--
You Have Two Choices For Dinner: Take It Or Leave It.

Nov 12 '05 #6
rkc

"Douglas J. Steele" <dj******@canada.com> wrote in message
news:xK********************@news01.bloor.is.net.ca ble.rogers.com...
Or possibly

If Len(Trim$(myTextBox.Value & "")) = 0 Then

to also catch those cases where the textbox contains one or more spaces, and nothing else.


Is it possible to enter one or more spaces, and nothing else, into a textbox
via the keyboard?
Nov 12 '05 #7
"rkc" <rk*@yabba.dabba.do.rochester.rr.com> wrote in
news:nu*******************@twister.nyroc.rr.com:
Is it possible to enter one or more spaces, and nothing else, into a
textbox via the keyboard?


It's not possible here in Canada (for me, anyway), but I've always assumed it
was there in the USA to faciliate entry of "Reasons for the Invasion of
Iraq", or "Location of Iraq's WMD Caches"?

--
Lyle

Nov 12 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: News Groups | last post by:
Hello Asp Programmers, I have a question. I have a form on an ASP page that has 5 text boxes, for data entry. I am trying to get data from the text box, and pass it to a hidden text box on...
7
by: RC | last post by:
I have a form with five text boxes on it. The format for all the boxes is set as General Number. In four of the boxes the user can enter a number, the fifth box totals up the values in the other...
1
by: gi75research | last post by:
What should be a very simple function is going terribly wrong, and I don't know why. StartTime and EndTime are table values (formatted like "01:00A" or "02:00P"); DaypartStart and DaypartEnd are...
6
by: EDOnLine | last post by:
New asp.net/webform user question...... I am trying to use the Custom Validator control to check to see if either of two fields on my form have been filled in. At this point all I am interested...
14
by: Xero | last post by:
Hello. I am using Visual Studio .NET (Academic Edition) to write a VB program. My computer is running Win XP Pro. I am writing a calculator and requires users to enter two numbers. After...
27
by: Josh | last post by:
We have a program written in VB6 (over 100,000 lines of code and 230 UI screens) that we want to get out of VB and into a better language. The program is over 10 years old and has already been...
2
by: Netkiller | last post by:
#!/usr/bin/python # -*- coding: utf-8 -*- """ Project: Network News Transport Protocol Server Program Description: 基于数据库的新闻组,实现BBS前端使用NNTP协议来访问贴子...
17
by: Petyr David | last post by:
Just looking for the simplest. right now my perl script returns an error messge to the user if the date string is invalid. would like to do this before accessing the server. TX
5
by: keri | last post by:
Hi, I have a table with 2 fields - flddate and category. The values of flddate are all working day dates (monday to friday dates between jan 2007 and 2010 (although the end date could change)....
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.