Why does this code not work?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jaad
    New Member
    • Oct 2009
    • 158

    Why does this code not work?

    I have a report where two controls should be dependent of the [moveINOUT] control on the same report.

    Code:
    Private Sub Report_Current()
        If MoveINOUT = "IN" Then
        NoteOUT.Visible = False
        RepairOUT.Visible = False
        
        Else
        
        If MoveINOUT = "OUT" Then
        NoteOUT.Visible = True
        RepairOUT.Visible = True
        
        End If
        End If
        
    End Sub
    I've tried a variation of ways and I don't get it, this code above should work???
    any ideas? thanks
  • mshmyob
    Recognized Expert Contributor
    • Jan 2008
    • 903

    #2
    Why do you have a nested if statement.

    If your only two posiible values for MoveINOUT are "IN" or "OUT" then you just need the following:

    [code=vb]

    If MoveINOUT = "IN" Then
    NoteOUT.Visible = False
    RepairOUT.Visib le = False
    Else
    NoteOUT.Visible = True
    RepairOUT.Visib le = True
    End If
    [/code]

    Keep in mind you did not mention what was "NOT WORKING".

    cheers,

    Comment

    • TheSmileyCoder
      Recognized Expert Moderator Top Contributor
      • Dec 2009
      • 2322

      #3
      A report has no "Current Event" (unless it was added in 2007 which I wouldn't know).

      Use Detail_Format or Detail_Print.

      Comment

      • jaad
        New Member
        • Oct 2009
        • 158

        #4
        Yes it is Access 2007 and yup, it does have an "On current"

        Comment

        • TheSmileyCoder
          Recognized Expert Moderator Top Contributor
          • Dec 2009
          • 2322

          #5
          Well try using detail_Format and see if that doesnt do it for you :)

          Comment

          • jaad
            New Member
            • Oct 2009
            • 158

            #6
            That doesn't work No.

            Comment

            • mshmyob
              Recognized Expert Contributor
              • Jan 2008
              • 903

              #7
              You still have not told us what is happening (ie: what is the error)

              Is any part of the if statement triggering?

              Where are the variables and how is the INOUT variable populated?

              Have you changed the code like I suggested?

              Important: What view are you opening the report in??? To get the Report.Current event to trigger the report must be run in Print Preview or Normal mode.

              etc.

              cheers,

              Comment

              Working...