473,608 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help: Using a Checkbox to Control a Date's Value

Hi everybody-

I'm trying to use a checkbox to control whether or not a date field in
a query "Is Null" or "Is Not Null."

I have 2 date fields: InDate and OutDate. If there is an OutDate, then
the record is finished. If there is no OutDate, then the record is not
finished.

I'm using an unbound form (frmStatus) to enter data into a query to
generate a report.

I have 2 unbound text boxes for the dates: txtInDate and txtOutDate. I
use these dates in the criteria for my InDate. I might enter the date
range: 1/1/04 to 7/1/04. My query retrieves all records with an InDate
between those dates.

I know that some of my records have null OutDates- a date hasn't been
entered yet. For instance some records have InDates and OutDates, and
some records have InDates and no OutDates.

If a record has an InDate and OutDate, then it is considered
"Completed. " If a record has an InDate and no OutDate, then it is
considered "Not Completed."

I have a checkbox on my unbound form named, "Completed. "

If I check the checkbox, then I want the query to return records where
there is an OutDate. If the checkbox is not checked, then I want the
query to return records with no OutDate.

Here is a example of my table, tblStatus:
RecordID
InDate
OutDate

Here is the criteria of the OutDate field in my query:

IIf([forms]![frmStatus]![Completed]=True,([tblStatus].[OutDate]) Is
Not Null,([tblStatus].[OutDate]) Is Null)
This doesn't work. So, I'm wondering if this possible to do with a
checkbox?

thanks!

Megan
Nov 13 '05 #1
6 1944
This is how I did it Megan, though being new to this I cannot for the life
of me think why your approach did not work, seems sensible to me...

Anyway,

1) I presume your query has InDate and OutDate columns.
2) I added a third calculated column to the query, 'Status', built as
follows: IIf([OutDate] Is Null,-1,0)
3) I then added a criteria to this 'Status' column thus:
[Forms]![frmStatus]![Completed]

As such, the value of the third column will be set to '0' (checkbox
unticked) or '-1' (checkbox ticked), and this is tested against the
'Completed' value on your form.

Hope this helps, worked for me,

Chris
"Megan" <me************ **@hotmail.com> wrote in message
news:5c******** *************** ***@posting.goo gle.com...
Hi everybody-

I'm trying to use a checkbox to control whether or not a date field in
a query "Is Null" or "Is Not Null."

I have 2 date fields: InDate and OutDate. If there is an OutDate, then
the record is finished. If there is no OutDate, then the record is not
finished.

I'm using an unbound form (frmStatus) to enter data into a query to
generate a report.

I have 2 unbound text boxes for the dates: txtInDate and txtOutDate. I
use these dates in the criteria for my InDate. I might enter the date
range: 1/1/04 to 7/1/04. My query retrieves all records with an InDate
between those dates.

I know that some of my records have null OutDates- a date hasn't been
entered yet. For instance some records have InDates and OutDates, and
some records have InDates and no OutDates.

If a record has an InDate and OutDate, then it is considered
"Completed. " If a record has an InDate and no OutDate, then it is
considered "Not Completed."

I have a checkbox on my unbound form named, "Completed. "

If I check the checkbox, then I want the query to return records where
there is an OutDate. If the checkbox is not checked, then I want the
query to return records with no OutDate.

Here is a example of my table, tblStatus:
RecordID
InDate
OutDate

Here is the criteria of the OutDate field in my query:

IIf([forms]![frmStatus]![Completed]=True,([tblStatus].[OutDate]) Is
Not Null,([tblStatus].[OutDate]) Is Null)
This doesn't work. So, I'm wondering if this possible to do with a
checkbox?

thanks!

Megan

Nov 13 '05 #2
This is how I did it Megan, though being new to this I cannot for the life
of me think why your approach did not work, seems sensible to me...

Anyway,

1) I presume your query has InDate and OutDate columns.
2) I added a third calculated column to the query, 'Status', built as
follows: IIf([OutDate] Is Null,-1,0)
3) I then added a criteria to this 'Status' column thus:
[Forms]![frmStatus]![Completed]

As such, the value of the third column will be set to '0' (checkbox
unticked) or '-1' (checkbox ticked), and this is tested against the
'Completed' value on your form.

Hope this helps, worked for me,

Chris
"Megan" <me************ **@hotmail.com> wrote in message
news:5c******** *************** ***@posting.goo gle.com...
Hi everybody-

I'm trying to use a checkbox to control whether or not a date field in
a query "Is Null" or "Is Not Null."

I have 2 date fields: InDate and OutDate. If there is an OutDate, then
the record is finished. If there is no OutDate, then the record is not
finished.

I'm using an unbound form (frmStatus) to enter data into a query to
generate a report.

I have 2 unbound text boxes for the dates: txtInDate and txtOutDate. I
use these dates in the criteria for my InDate. I might enter the date
range: 1/1/04 to 7/1/04. My query retrieves all records with an InDate
between those dates.

I know that some of my records have null OutDates- a date hasn't been
entered yet. For instance some records have InDates and OutDates, and
some records have InDates and no OutDates.

If a record has an InDate and OutDate, then it is considered
"Completed. " If a record has an InDate and no OutDate, then it is
considered "Not Completed."

I have a checkbox on my unbound form named, "Completed. "

If I check the checkbox, then I want the query to return records where
there is an OutDate. If the checkbox is not checked, then I want the
query to return records with no OutDate.

Here is a example of my table, tblStatus:
RecordID
InDate
OutDate

Here is the criteria of the OutDate field in my query:

IIf([forms]![frmStatus]![Completed]=True,([tblStatus].[OutDate]) Is
Not Null,([tblStatus].[OutDate]) Is Null)
This doesn't work. So, I'm wondering if this possible to do with a
checkbox?

thanks!

Megan

Nov 13 '05 #3
This is how I did it Megan, though being new to this I cannot for the life
of me think why your approach did not work, seems sensible to me...

Anyway,

1) I presume your query has InDate and OutDate columns.
2) I added a third calculated column to the query, 'Status', built as
follows: IIf([OutDate] Is Null,-1,0)
3) I then added a criteria to this 'Status' column thus:
[Forms]![frmStatus]![Completed]

As such, the value of the third column will be set to '0' (checkbox
unticked) or '-1' (checkbox ticked), and this is tested against the
'Completed' value on your form.

Hope this helps, worked for me,

Chris

"Megan" <me************ **@hotmail.com> wrote in message
news:5c******** *************** ***@posting.goo gle.com...
Hi everybody-

I'm trying to use a checkbox to control whether or not a date field in
a query "Is Null" or "Is Not Null."

I have 2 date fields: InDate and OutDate. If there is an OutDate, then
the record is finished. If there is no OutDate, then the record is not
finished.

I'm using an unbound form (frmStatus) to enter data into a query to
generate a report.

I have 2 unbound text boxes for the dates: txtInDate and txtOutDate. I
use these dates in the criteria for my InDate. I might enter the date
range: 1/1/04 to 7/1/04. My query retrieves all records with an InDate
between those dates.

I know that some of my records have null OutDates- a date hasn't been
entered yet. For instance some records have InDates and OutDates, and
some records have InDates and no OutDates.

If a record has an InDate and OutDate, then it is considered
"Completed. " If a record has an InDate and no OutDate, then it is
considered "Not Completed."

I have a checkbox on my unbound form named, "Completed. "

If I check the checkbox, then I want the query to return records where
there is an OutDate. If the checkbox is not checked, then I want the
query to return records with no OutDate.

Here is a example of my table, tblStatus:
RecordID
InDate
OutDate

Here is the criteria of the OutDate field in my query:

IIf([forms]![frmStatus]![Completed]=True,([tblStatus].[OutDate]) Is
Not Null,([tblStatus].[OutDate]) Is Null)
This doesn't work. So, I'm wondering if this possible to do with a
checkbox?

thanks!

Megan

Nov 13 '05 #4
Hi Megan

You can't use "Is Null" or "Is Not Null" to *set* a value to Null.

These operators are used to *test* a field or control's value.

For example:
This query will return all records that do NOT have an OutDate:
SELECT tblStatus.*
FROM tblStaus
WHERE (((tblStaus.Out Date) Is Null));

This query will return all records that DO have an OutDate:
SELECT tblStatus.*
FROM tblStaus
WHERE (((tblStaus.Out Date) Is Not Null));

It sounds like what you want to do is use the "Completed" checkbox control's
After Update event
to test and set the value of "OutDate", something like this:

(AirCode)
*************** *************** *********
Private Sub Completed_After Update()

If Me![Completed] = True Then
Me![OutDate] = Date()
Else
Me![OutDate] = Null
End If

End Sub
*************** *************** *********

HTH,
Don
"Megan" <me************ **@hotmail.com> wrote in message
news:5c******** *************** ***@posting.goo gle.com...
Hi everybody-

I'm trying to use a checkbox to control whether or not a date field in
a query "Is Null" or "Is Not Null."

I have 2 date fields: InDate and OutDate. If there is an OutDate, then
the record is finished. If there is no OutDate, then the record is not
finished.

I'm using an unbound form (frmStatus) to enter data into a query to
generate a report.

I have 2 unbound text boxes for the dates: txtInDate and txtOutDate. I
use these dates in the criteria for my InDate. I might enter the date
range: 1/1/04 to 7/1/04. My query retrieves all records with an InDate
between those dates.

I know that some of my records have null OutDates- a date hasn't been
entered yet. For instance some records have InDates and OutDates, and
some records have InDates and no OutDates.

If a record has an InDate and OutDate, then it is considered
"Completed. " If a record has an InDate and no OutDate, then it is
considered "Not Completed."

I have a checkbox on my unbound form named, "Completed. "

If I check the checkbox, then I want the query to return records where
there is an OutDate. If the checkbox is not checked, then I want the
query to return records with no OutDate.

Here is a example of my table, tblStatus:
RecordID
InDate
OutDate

Here is the criteria of the OutDate field in my query:

IIf([forms]![frmStatus]![Completed]=True,([tblStatus].[OutDate]) Is
Not Null,([tblStatus].[OutDate]) Is Null)
This doesn't work. So, I'm wondering if this possible to do with a
checkbox?

thanks!

Megan

Nov 13 '05 #5
me************* *@hotmail.com (Megan) wrote in message news:<5c******* *************** ****@posting.go ogle.com>...
Hi everybody-

I'm trying to use a checkbox to control whether or not a date field in
a query "Is Null" or "Is Not Null."

I have 2 date fields: InDate and OutDate. If there is an OutDate, then
the record is finished. If there is no OutDate, then the record is not
finished.

I'm using an unbound form (frmStatus) to enter data into a query to
generate a report.

I have 2 unbound text boxes for the dates: txtInDate and txtOutDate. I
use these dates in the criteria for my InDate. I might enter the date
range: 1/1/04 to 7/1/04. My query retrieves all records with an InDate
between those dates.

I know that some of my records have null OutDates- a date hasn't been
entered yet. For instance some records have InDates and OutDates, and
some records have InDates and no OutDates.

If a record has an InDate and OutDate, then it is considered
"Completed. " If a record has an InDate and no OutDate, then it is
considered "Not Completed."

I have a checkbox on my unbound form named, "Completed. "

If I check the checkbox, then I want the query to return records where
there is an OutDate. If the checkbox is not checked, then I want the
query to return records with no OutDate.

Here is a example of my table, tblStatus:
RecordID
InDate
OutDate

Here is the criteria of the OutDate field in my query:

IIf([forms]![frmStatus]![Completed]=True,([tblStatus].[OutDate]) Is
Not Null,([tblStatus].[OutDate]) Is Null)
This doesn't work. So, I'm wondering if this possible to do with a
checkbox?

thanks!

Megan


Easiest way to do this is with code behind a button on your form.
If ([forms]![frmStatus]![Completed]=True Then
'open the first query
DoCmd.OpenQuery "qryComplet ed"
Else
'open the second query
DoCmd.Openquery "qryIncompl ete"
End If

Alternatively, create a report to show the data you want (NOT
filtered), and then pass the filter to it when you open the report.
Nov 13 '05 #6
Thank-you eveyone for the ideas, suggestions, and code! I figured out
an alternate way to do what I wanted. Check it out:

I used this code behind the On Click Event of my Print Preview Command
Button.

............... ............... ............... ............... ............... ....

Dim stDocName As String
Dim stCompleted As String
Dim stNotCompleted As String

stDocName = "MyReport"

If Me.Completed.Va lue = True Then
stCompleted = "[OutDate] Is Not Null"
DoCmd.OpenRepor t stDocName, acViewPreview, , stCompleted
ElseIf Me.Completed.Va lue = False Then
stNotCompleted = "[OutDate] = Is Null"
DoCmd.OpenRepor t stDocName, acViewPreview, , stNotCompleted
End If

............... ............... ............... ............... ............... ....

It worked out perfectly for me although I'm not totally sure why. I'm
still new with VBA so I'm not really familiar with all of the
commands.

Thanks again everyone!

Megan
me************* *@hotmail.com (Megan) wrote in message news:<5c******* *************** ****@posting.go ogle.com>...
Hi everybody-

I'm trying to use a checkbox to control whether or not a date field in
a query "Is Null" or "Is Not Null."

I have 2 date fields: InDate and OutDate. If there is an OutDate, then
the record is finished. If there is no OutDate, then the record is not
finished.

I'm using an unbound form (frmStatus) to enter data into a query to
generate a report.

I have 2 unbound text boxes for the dates: txtInDate and txtOutDate. I
use these dates in the criteria for my InDate. I might enter the date
range: 1/1/04 to 7/1/04. My query retrieves all records with an InDate
between those dates.

I know that some of my records have null OutDates- a date hasn't been
entered yet. For instance some records have InDates and OutDates, and
some records have InDates and no OutDates.

If a record has an InDate and OutDate, then it is considered
"Completed. " If a record has an InDate and no OutDate, then it is
considered "Not Completed."

I have a checkbox on my unbound form named, "Completed. "

If I check the checkbox, then I want the query to return records where
there is an OutDate. If the checkbox is not checked, then I want the
query to return records with no OutDate.

Here is a example of my table, tblStatus:
RecordID
InDate
OutDate

Here is the criteria of the OutDate field in my query:

IIf([forms]![frmStatus]![Completed]=True,([tblStatus].[OutDate]) Is
Not Null,([tblStatus].[OutDate]) Is Null)
This doesn't work. So, I'm wondering if this possible to do with a
checkbox?

thanks!

Megan

Nov 13 '05 #7

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

Similar topics

9
3953
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it will not set the value of the control and will leave the checked status of the checkbox to false when a user selects a new date. this works fine when using the control on a win2k machine but if we use it on a win XP box and call
3
5221
by: Moe Sizlak | last post by:
Hi, Can I check a checkbox by default based on the value returned from a database? for example if the value (dr("frm7value")) returned from a db field is "YES" how can I check the checkbox by default? Moe
32
12501
by: robert d via AccessMonster.com | last post by:
I'm looking at converting DAO to ADO in my app. All of my DAO connections are of the following structure: Dim wsName As DAO.Workspace Dim dbName As DAO.Database Dim rsName As DAO.Recordset Set wsName = DBEngine.Workspaces(0) Set dbName = wsName.OpenDatabase(CurrentProject.FullName) Set rsName = dbName.OpenRecordset("SQL Statement")
0
2248
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional assistance. I say additional because I've already had help which is greatly appreciated. I do try to take the time and understand the provided script in hopes on not having to trouble others on those. But here it goes...
1
1270
by: dokter.cinta | last post by:
hi all.... i have good experience with vb but i have some serious problems i have created a mysql with table dss but i`m confused about this i think many people will have this problem in future this is the table of dss ================== date (data type = date)
6
4304
by: D | last post by:
Hello all...I have an issue with one of my java script functions that I'm hoping someone can easily help with. I have a web based application that we use to create/sign up for overtime. When we have holidays we require our employees to sign up in 4 hr increments for the times we post. I'm having trouble creating a time slot that ends @ 12am. 12pm and all other hours work fine for start/end times. however 12am causes problems. My actual...
0
5556
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
3
3002
by: cuties | last post by:
Hi all.... i'm very new to this programming language. i'm required to fulfill this task in the company i'm doing my practical. i hope i can get guide for my problem... Here is the script i already wrote but i'm having problem to move forward. my problem is : 1. how do i assign each checkbox to have equal value with the value of the d_id?
0
2839
by: richard12345 | last post by:
Hi Guys I have problem with site I am building. The sidebar with menu and other thinks is overlapping footer. The footer move with the content and but it dos it dos not move with the sidebar. Here is the website: holtz-realty And also the html file and css file. Anny help will by mostly appreciated. I did try everything I can think of. HTML:
0
8063
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8003
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8478
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8341
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5476
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3962
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4025
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1331
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.