Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2009
    Posts
    3

    Unhappy Unanswered: Get txt in Report to show/not show based on Fields in Form

    Hello all!

    I happened to stumble across this board and I hope all you pros out there can help me out. I'm relatively new to programming/VBA in general, so bare with me.


    What I'm trying to do, is get a txt to appear in a report, but only if certain fields on a form says so.

    For example, in a form, I have a smoking combobox and if that box says "Yes", then I want, when a report is generated, to show a certain txt field, ie. "This patient needs to stop smoking.". But, at the same time, if another sleep combobox is also "yes", then I want the report to show:

    "-This patient needs to stop smoking.
    -Patient also needs more sleep "

    In other words, new txt are added and they're together with no spaces, and that a txt field to be able to grow in a sense, though with pre-determined txt.

    I already am able to get a report generated based on certain fields in the form, but it's just this dynamic txt thing that I'm having a problem with.

    My current method, though a little inefficient, is to have various footers with the txt that I want to show. And using the:

    If Forms!MasterTable.TriageOptionsSmoking = "Yes" Then
    triageSmokingFooter.Visible = True
    Else
    triageSmokingFooter.Visible = False
    End If

    Im wondering if there's a more efficient way. Because these headers and footers are required to be connected to a table, which I'm reluctant to keep making just for the point of having these txt show up.

    Sorry for the long post, but if anyone could help me get started, I would really appreciate it.

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    One option:

    Code:
    If Forms!MasterTable.TriageOptionsSmoking = "Yes" Then ReportTextBoxName = ReportTextBoxName & "Patient is an idiot" & vbcrlf
    If Forms!MasterTable.TriageOptionsSleep = "Yes" Then ReportTextBoxName = ReportTextBoxName & "Patient needs a pillow." & vbcrlf
    ...
    Make the text box "Can Grow".
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Apr 2005
    Location
    Zagreb - Croatia
    Posts
    372
    Look at "DemoRptYesNoA2000.mdb" (attachment, zip).
    Look at Table1, Form1, Report1.
    Open Form and try.
    Attached Files Attached Files

  4. #4
    Join Date
    Aug 2009
    Posts
    3
    Quote Originally Posted by MStef-ZG
    Look at "DemoRptYesNoA2000.mdb" (attachment, zip).
    Look at Table1, Form1, Report1.
    Open Form and try.
    Hey Mstef-ZG, thanks for the sample.

    My only concern with this code:

    Select Case Me.YesNo
    Case 0
    Me.Message = ""
    Case 1
    Me.Message = "This patient needs to stop smoking."
    Case Else
    Me.Message = "This patient needs to stop smoking. Patient also needs more sleep."
    End Select

    Is that in the case where I only want "patient also needs more sleep", without the "This patient needs to stop smoking.", I wouldn't be able to do that. Am i mistaken?

  5. #5
    Join Date
    Aug 2009
    Posts
    3

    Smile

    Quote Originally Posted by StarTrekker
    One option:

    Code:
    If Forms!MasterTable.TriageOptionsSmoking = "Yes" Then ReportTextBoxName = ReportTextBoxName & "Patient is an idiot" & vbcrlf
    If Forms!MasterTable.TriageOptionsSleep = "Yes" Then ReportTextBoxName = ReportTextBoxName & "Patient needs a pillow." & vbcrlf
    ...
    Make the text box "Can Grow".
    StarTrekker

    Works like a charm.

    Thank you very much!
    AKP

  6. #6
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    You're most welcome
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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