473,416 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

When Checkbox is Checked on Form, want report to print Yes/No

Hi -
I've looked at many posts, and cannot find the answer on this specific
problem.

I have several fields on a table, which I've defined as "Text", 3
characters, Format Yes/No (I picked up the Text and Format Yes/No from
a Posting).

I have a form with a label and a check box for each item and the user
checks off the ones s/he wants to be "Yes".
Then, I print the value on different reports - and on the reports I
want "Yes" or "No" to print.

However, the reports are printing -1 for "yes" and "No" for "No". I
think this is because the table default value is "No", so they show
"No".

I can see that when I check a box on the form, the table value is -1,
and the display is -1.

Is there a way to have the checkbox, when checked "On" put "Yes" in
the table, and when checked "Off" (like if the user changed a "Yes" to
a "No"), put a "No" value in the table?

Thanks - Much appreciated.
Sara

On

Apr 6 '07 #1
4 13646
Hi Sara,

One option is to write a little bit of code in your report. Add a
Report level Recordset variable named RS just underneath
Option Compare Database
Option Explicit

Actually, Here is my sample code which uses a table called Table2 that
contains 2 fields, a Name field and a yes/no field that I named YesNo.
What I did was to set the Recordsource of the report to Table2 in the
Report initial creation. Then I added this code which will also work if
your table contains several fields:

------------------------------------------------------
Option Compare Database
Option Explicit

Dim RS As Recordset

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If RS!YesNo = 0 Then Text2 = "No"
If RS!YesNo = -1 Then Text2 = "Yes"
RS.MoveNext
End Sub

Private Sub Report_Open(Cancel As Integer)
Set RS = CurrentDb.OpenRecordset("Table2")
End Sub

--------------------------------------------------

Just replace "Table2" with your table Name and change
RS!YesNO to your yes/no fieldname.

HTH

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Apr 6 '07 #2
I forgot to mention, the Text2 is an unbound textbox in the report
detail section. The other fields from your table will be bound to the
table fields. Just make the yes/no field unbound (just an ordinary
unbound textbox) and you populate the textbox with the code above.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Apr 6 '07 #3
Hi Sara,

In your table design ... Why did you choose "Text" as the data type ... and
not "Yes/No"?
I'd start by making that change right off the bat.
While you're in the table design view, and after you have changed the
field's data type to "Yes/No", have a look at the field's property sheet.
If you click in the "Format" row of the property sheet, it becomes a
combo-box ... giving you 3 display options (Yes/No, True/False, On/Off)
("Display options" is the operative phrase here. The data really is 0 for
False, and -1 for True ... formatting it just changes the result displayed.)

Whatever format you choose here will be the DEFAULT format for all
newly-created forms and reports. Keep in mind that the format can be changed
at will on whatever form or report you want. Just change the Format setting
in the control's property sheet.

Actually, you may even be able to do that with things set up the way you
have them right now ... but I DO encourage you to change the Data Type of
the field at the table design level.
--
--
HTH,
Don
=============================
E-Mail (if you must) My*****@Telus.net

Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)

I'm an Access97 user, so all posted code samples are also Access97- based
unless otherwise noted.

================================================== ========================
"sara" <sa*******@yahoo.comwrote in message
news:11**********************@b75g2000hsg.googlegr oups.com...
Hi -
I've looked at many posts, and cannot find the answer on this specific
problem.

I have several fields on a table, which I've defined as "Text", 3
characters, Format Yes/No (I picked up the Text and Format Yes/No from
a Posting).

I have a form with a label and a check box for each item and the user
checks off the ones s/he wants to be "Yes".
Then, I print the value on different reports - and on the reports I
want "Yes" or "No" to print.

However, the reports are printing -1 for "yes" and "No" for "No". I
think this is because the table default value is "No", so they show
"No".

I can see that when I check a box on the form, the table value is -1,
and the display is -1.

Is there a way to have the checkbox, when checked "On" put "Yes" in
the table, and when checked "Off" (like if the user changed a "Yes" to
a "No"), put a "No" value in the table?

Thanks - Much appreciated.
Sara

On

Apr 6 '07 #4
On Apr 6, 7:00 pm, "Don Leverton" <leveriteNoJunkM...@telusplanet.net>
wrote:
Hi Sara,

In your table design ... Why did you choose "Text" as the data type ... and
not "Yes/No"?
I'd start by making that change right off the bat.
While you're in the table design view, and after you have changed the
field's data type to "Yes/No", have a look at the field's property sheet.
If you click in the "Format" row of the property sheet, it becomes a
combo-box ... giving you 3 display options (Yes/No, True/False, On/Off)
("Display options" is the operative phrase here. The data really is 0 for
False, and -1 for True ... formatting it just changes the result displayed.)

Whatever format you choose here will be the DEFAULT format for all
newly-created forms and reports. Keep in mind that the format can be changed
at will on whatever form or report you want. Just change the Format setting
in the control's property sheet.

Actually, you may even be able to do that with things set up the way you
have them right now ... but I DO encourage you to change the Data Type of
the field at the table design level.

--
--
HTH,
Don
=============================
E-Mail (if you must) My.N...@Telus.net

Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)

I'm an Access97 user, so all posted code samples are also Access97- based
unless otherwise noted.

================================================== ========================

"sara" <saraqp...@yahoo.comwrote in message

news:11**********************@b75g2000hsg.googlegr oups.com...
Hi -
I've looked at many posts, and cannot find the answer on this specific
problem.
I have several fields on a table, which I've defined as "Text", 3
characters, Format Yes/No (I picked up the Text and Format Yes/No from
a Posting).
I have a form with a label and a check box for each item and the user
checks off the ones s/he wants to be "Yes".
Then, I print the value on different reports - and on the reports I
want "Yes" or "No" to print.
However, the reports are printing -1 for "yes" and "No" for "No". I
think this is because the table default value is "No", so they show
"No".
I can see that when I check a box on the form, the table value is -1,
and the display is -1.
Is there a way to have the checkbox, when checked "On" put "Yes" in
the table, and when checked "Off" (like if the user changed a "Yes" to
a "No"), put a "No" value in the table?
Thanks - Much appreciated.
Sara
On- Hide quoted text -

- Show quoted text -
Thanks, Don - I did it!

The key was where you said "a new report" will show the changes. And
it did!

The reason I set it up the way I did is that I first did Yes/No and I
saw Check boxes in the table and didn't like that. So, I looked in
this user group and got the solution for Text and yes/no formatting.
When that still didn't work, I posted my problem myself.,

You might be right that it might have worked my way if I'd done a new
report, but this works, so I'm moving on.

Again, MANY thanks.

sara

Apr 7 '07 #5

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

Similar topics

1
by: John Mullen | last post by:
I want to take the following HTLM and use javascript to turn on radio buttons if checkbox is checked, can I do this with javascript (maybe onClick or an array) or do i need a server side script ?...
12
by: zig | last post by:
I've posted this on alt.comp.lang.coldfusion, but is predominantly a javascript problem: I have a CF query which returns several rows of records. I wanted to have a checkbox on each record of...
3
by: Rich | last post by:
I have a form with 2 check boxes. One of the check boxes is used to specify that the user is a "primary contact." When I check the primary contact box I want a second box for "standard contact"...
4
by: Piotr | last post by:
how can I read (in alert for example) array index number of checked checkbox? I have: <input type="checkbox" id="id_number" name="check" value="1" onclick="show()"/> <input type="checkbox"...
6
by: Megan | last post by:
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...
2
by: /.. | last post by:
Hi all, I'm working on a report display page that currently uses 5 checkboxlists with a total of 86 items to display values from 5 different tables in an Access database. The page works fine...
1
by: dx | last post by:
I'm extremely frustrated with ASP.NET...again! To me this should be as simple as setting oCheckBox.Checked = True.. yet for some reason it isn't. I have a user control (ascx) that that has a...
34
by: clinttoris | last post by:
Hello Experts, I have been told to post this in the Javascript forum as I want to do this client side just before my form gets submitted. Once the user clicks the submit button a javascript...
6
by: jinfo | last post by:
I was assigned the task of creating a small database by my office. I created a table with the appropriate field ID, Project, and Approve (checkbox). Then I created a Form of the table. But when...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.