Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Kontich, Vlaanderen, Belgium
    Posts
    103
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Print text on a report if a checkbox is checked

    Hi all,

    I would like to do the following in Access 97 - SR 2 :

    On a report I would like to have a standard text printed, but only when a specific check box is checked. If the check box is clear, the standard text should not be printed.

    This standard text is immediately followed by some more text that comes from another field. If the check box is clear then just the other text should be on the report.

    I will try to illustrate what I mean :

    If the check box is checked :

    This is the standard text. And here follows the other text.

    If the check box is clear :

    Here comes the other text.

    As I am a novice to Access, I hope there is a simple solution to this problem. I always use the Report wizard to make my reports, and have no experience with other ways to make reports. (Maybe I should spend some time on this, any suggestion where to find a "Making reports for dummies" training on the Internet ?)

    Best regards,

    Walter

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print text on a report if a checkbox is checked

    The exact solution depends on whether the two bits of text are static (fixed) or variable (values of a field in the record source).

    Open the report in design view.
    Make sure that the Toolbox toolbar is visible (View | Toolbox, or Toolbox button on the Report Design toolbar).
    Click on the Text Box button on the toolbar, then in the Detail section of the report.
    This creates a new unbound text box; you can drag it to the desired position, and resize it.
    Make sure that the Properties window is visible (View | Properties, or Properties button on the Report Design toolbar).
    Activate the Data tab of the Properties window.
    With the text box still selected, enter the following into the Control Source property:

    <code>=IIf([ysnField],"This is the standard text. ","") & "This is the other text."</code>

    where ysnField is the name of the yes/no field associated with the check box. The above version is for static text; if the text comes from fields in the record source, use this:

    <code>=IIf([ysnField],[NameOfOneField],"") & [NameOfOtherField]</code>

    with the appropriate field names substituted. The IIf (Immediate If) function tests if the first argument is True. If so, it returns the second argument, otherwise, it returns the third argument.

    NOTE: if you use Dutch/Flemish Windows settings, you will probably need to use a semicolon ; instead of a comma , to separate the arguments in the IIf function.

    You can look up "examples of expressions" in the online help.

  3. #3
    2 Star Lounger
    Join Date
    Apr 2003
    Location
    Kontich, Vlaanderen, Belgium
    Posts
    103
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print text on a report if a checkbox is checked

    Thank you Hans,

    Although I have a mixture of the text fields : one being static, the other variable, your solution works fine for me.

    Problem solved !

    Best regards,
    Walter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •