469,282 Members | 2,000 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

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 13170
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by John Mullen | last post: by
4 posts views Thread by Piotr | last post: by
2 posts views Thread by /.. | last post: by
34 posts views Thread by clinttoris | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.