Checkbox issues

G

Guest

Hello All!

I have a two part question regarding checkboxes.

1. On the form I have a field called "Date Completed". Next to this field I
want to place an unbound checkbox. If a date is filled in I want the checkbox
checked. If no date is filled in (or left blank) I want the checkbox left
blank. How do I accomplish this?

2. On a report, how do I show this checkbox? Do I need to add it a table and
therefore make it bound? When the user pulls a report, I want to query the
data so only the records that this checkbox is checked show. Anything not
check I do not want to show. I am a novice with Access so please simplify
answers.

Thanks!!
 
S

SusanV

Hi Doug,

I'm assuming you want this checkbox for reasons other than to be the basis
of the report 's data source - as a visual aid for your users perhaps? IF
it's only to get the data source for the report, skip 1 and go to 2.


1. In the forms OnCurrent Event:
me.checkbox = not IsNull(me.datedcompleted)

For "Live updates" during data entry, repeat the same code in the
"datecompleted" textbox control's OnUpdate Event:
me.checkbox = not IsNull(me.datedcompleted)


2. You don't have to store this checkbox at all - your query for the report
should be defined as:
"SELECT * FROM MyTable WHERE MyTable.datacompleted Is Not Null"

Actual field and control names will need to be used for the above to work.
 
J

John Vinson

Hello All!

I have a two part question regarding checkboxes.

1. On the form I have a field called "Date Completed". Next to this field I
want to place an unbound checkbox. If a date is filled in I want the checkbox
checked. If no date is filled in (or left blank) I want the checkbox left
blank. How do I accomplish this?

Set the Control Source of the checkbox control to

=Not IsNull(Me![Date Completed])

In my opinion this checkbox is pretty useless, though - the user can
SEE if there is a date in the textbox or not, and the checkbox just
says "yes, there's a date in the textbox, just like you can see if you
look"!
2. On a report, how do I show this checkbox? Do I need to add it a table and
therefore make it bound? When the user pulls a report, I want to query the
data so only the records that this checkbox is checked show. Anything not
check I do not want to show. I am a novice with Access so please simplify
answers.

You don't need the checkbox in your query. Simply base the Report on a
query with

IS NOT NULL

as a criterion on the [Date Completed] field.


John W. Vinson[MVP]
 
G

Guest

Doug_C said:
Hello All!

I have a two part question regarding checkboxes.

1. On the form I have a field called "Date Completed". Next to this field I
want to place an unbound checkbox. If a date is filled in I want the checkbox
checked. If no date is filled in (or left blank) I want the checkbox left
blank. How do I accomplish this?
In the After Update event of your Date Completed Text Box (not a field,
fields are in tables):
If IsNull(Me![Date Completed]) Then
Me!chkMyCheckBox = False
Else
Me!chkMyCheckBox = True
End If

You should also put this code in the Form's Current event so you get the
correct value in the check box for existing records.
2. On a report, how do I show this checkbox? Do I need to add it a table and
therefore make it bound? When the user pulls a report, I want to query the
data so only the records that this checkbox is checked show. Anything not
check I do not want to show. I am a novice with Access so please simplify
answers.
You don't need an additional field. Filter your report on Not IsNull([Date
Completed])
 
G

Guest

You folks are great! I always count on this site for help and it's very rare
I am unable to get answer. Thank you all for your help, your knowledge is
very much appreciated!!

Doug

Klatuu said:
Doug_C said:
Hello All!

I have a two part question regarding checkboxes.

1. On the form I have a field called "Date Completed". Next to this field I
want to place an unbound checkbox. If a date is filled in I want the checkbox
checked. If no date is filled in (or left blank) I want the checkbox left
blank. How do I accomplish this?
In the After Update event of your Date Completed Text Box (not a field,
fields are in tables):
If IsNull(Me![Date Completed]) Then
Me!chkMyCheckBox = False
Else
Me!chkMyCheckBox = True
End If

You should also put this code in the Form's Current event so you get the
correct value in the check box for existing records.
2. On a report, how do I show this checkbox? Do I need to add it a table and
therefore make it bound? When the user pulls a report, I want to query the
data so only the records that this checkbox is checked show. Anything not
check I do not want to show. I am a novice with Access so please simplify
answers.
You don't need an additional field. Filter your report on Not IsNull([Date
Completed])
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top