Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2010
    Posts
    10

    Unanswered: Want certain fields to appear on report.

    Hi everyone,

    I figured out how to get my report to display only ONE record from my form.

    Now the next step is I need the report (from the form) to show ONLY certain data.

    What I have are fields and checkboxes.

    I want ONLY the fields below 4 to show and the checkboxes which are NOT checked to show in the report.

    I figured that I would link the report to a query, but I'm not sure how I would go about doing the checkboxes and values below 4.

    For example: I want to show if and only if the values for Q1-Q10 are less than 4 and Q11-Q20 are NO (unchecked).

    If they do NOT meet this criteria, then do NOT show them at all in the report.

    Each Q is a field in itself so first i filter which ID in the record to show (already done) then how do i further filter this specific ID to show only the fields which meet this criteria.

    Thanks.

  2. #2
    Join Date
    Jan 2010
    Posts
    13
    use the reports open event, something like this:

    Private Sub Report_Open(Cancel As Integer)

    if Q1 = something then Q1.visible = false

    End sub

    you need to use an if statement to test the value in a box, then simply set the controls visible field to false to hide it.

  3. #3
    Join Date
    Jan 2010
    Posts
    10
    Hey thanks for the reply, actually im still a newb in VB and SQL and I'm not sure where and how to fit the code you gave me.

    Currently when I click on the report button it opens a report with the current record. The code is:

    Private Sub reportbtn_Click()

    Dim strWhere As String

    If Me.Dirty Then 'Save any edits.
    Me.Dirty = False
    End If

    If Me.NewRecord Then 'Check there is a record to print
    MsgBox "Select a record to print"
    Else
    strWhere = "[ID] = " & Me.[ID]
    DoCmd.OpenReport "Showroom1", acViewPreview, , strWhere
    DoCmd.OpenReport "Showroom2", acViewPreview, , strWhere


    End If



    End Sub

    Now if I want the field EN01 to DISAPPEAR if its 4, how do I incorporate that into the code?

    Thanks.

  4. #4
    Join Date
    Jan 2010
    Posts
    13
    What you want to do, is right click on the report in the objects pane on the left hand side of access 2007 and select "design view" then in the properties sheet, select the events tab and click on the button beside "on open" event, this will bring you to the vba editor window where you can write code that will execute in the report open event. (when the report is opened)

    I've attached a screen cap, have a look at it below.

    You also may want to read a little on vba, it's an easy language, just requires a little reading and practice.


    field en01 is bound to what control on the report ? textbox, combobox ? whatever control that field is bound to, all you have to do is simply:


    If [En01] = 4 then txtboxEN01.visible = false

    this code would go in the open event of the report, so when the report opens up, then it checks the field value if it's 4, and makes the control (combo box, checkbox, text box, whatever the control is) invisible, by setting it's visible property to false
    Attached Thumbnails Attached Thumbnails ReportOpenEvent.JPG  
    Last edited by preacher23; 01-18-10 at 19:08.

  5. #5
    Join Date
    Jan 2010
    Posts
    10
    Hey thanks for your help, its still not working. When I enter

    If [EN01].Value = 4 Then EN01.Visible = False

    AND

    If [EN01] = 4 Then EN01.Visible = False

    Am getting:

    runtime error 2424

    Expression or field not found.

  6. #6
    Join Date
    Jan 2010
    Posts
    13
    it's not the field that you can make invisible, it's the control. A bound control to a specific field. You evaluate the field by:

    If EN01 = 4 then [Control1].visible = False

    EN01 is a field

    but which control is this field bound to ? a combo box, a text box ? a checkbox ? what's the name of the control/checkbox?, whatever the name is, that's what u will use in vba to set it's visible property to false. You can't set a field's visible property, it's a field, you need to set the bound control's visible property to false

Posting Permissions

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