Consulting

Results 1 to 10 of 10

Thread: If statement inside With block not executing

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Oct 2013
    Posts
    17
    Location

    If statement inside With block not executing

    Hi,
    I have a database of songs on MS Access which then produces a PowerPoint presentation of the chosen songs with each verse on a different slide. This all works fine but now I would like to add in an option in the database to tick a check box if the words are part of the song chorus which should then make that slide in italics. I have tried this:
    For intVerse = 16 To 1 Step -1        
    If IsNull(rs.Fields("Song " & intItem & " chosen_Verse " & intVerse).Value) Then
          '------
    Else        
        With .Slides.Add(rs.AbsolutePosition + 1, ppLayoutLargeObject)
               .FollowMasterBackground = False
               .Background.Fill.Solid
               .Background.Fill.ForeColor.RGB = RGB(0, 0, 0)
    
               With .NotesPage.Shapes.Placeholders(2)
                      .TextFrame.TextRange.Text = rs.Fields("Song " & intItem & " chosen.Notes")
               End With
    
               With .Shapes(1).TextFrame.TextRange
                      .Text = CStr(rs.Fields("Song " & intItem & " chosen_Verse " & intVerse).Value)
                      .Characters.Font.Color.RGB = RGB(255, 255, 255)
                      .Characters.Font.Size = 30
    
                      If (rs.Fields("Song " & intItem & " chosen.Chorus" & intVerse).Value) = True Then    '-- THIS STATEMENT NOT WORKING
                          .Characters.Font.Italic = True
                      Else
                           .Characters.Font.Italic = False
                      End If
    
                      .ParagraphFormat.Bullet = False
                      .ParagraphFormat.Alignment = ppAlignCenter             
                End With
                    
                If IsNull(rs.Fields("Song " & intItem & " chosen_Verse " & intVerse + 1).Value) Then
                     With .Shapes.AddTextbox(msoTextOrientationHorizontal, Left:=46.5, Top:=474, Width:=627, Height:=51).TextFrame.TextRange
                          .Text = rs.Fields("Song " & intItem & " chosen.Copyright Info")
                          .Characters.Font.Color.RGB = RGB(255, 255, 255)
                          .Font.Size = 14
                          .ParagraphFormat.Alignment = ppAlignRight
                      End With
                Else
                End If
           End With
        '--------------------------------------------------------------------------------------------------------------------
    End If
    
    Next intVerse
    Next intItem
    But this code seems to be ignoring the IF statement and just putting everything into italics even if the checkbox (Chorus1) is not ticked. Any ideas?
    Last edited by SamT; 06-03-2022 at 08:12 AM. Reason: Reformatted White Space

Posting Permissions

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