If ..Else.. End If "Compile Error: Else without If" what have i missed?

ok, yes, i had just figured out myself also that it ought to be just the form name in the function parameter like Rich said.

i have modified my report slightly (prettier and layed out better), and have it all working with this code (i would have posted this before, but i didn't have internet access):

Code:
Private Sub Report_Load()

' first check whether the form with the checkbox is open
If IsLoaded("frmLISTS") Then

    ' then apply correct visibility property settings
    If Forms!frmLISTS.chkReportDetails = False Then ' details not checked

        MsgBox "Not Checked"

           Me.Section(0).Visible = False ' detail section
           Me.Section(3).Visible = False ' page header
           Me.txtSummary_Criteria.Visible = False
           Me.lblSummary_Criteria.Visible = False
           Me.txtSummary_Cycle.Visible = False
           Me.lblSummary_Cycle.Visible = False

    Else ' details checked, show all sections
    
        MsgBox "Checked"

    End If

    MsgBox "Form Loaded"

Else ' checkbox unavailable, show all sections as default
    
    MsgBox "Form Not Loaded"

End If
    
End Sub

the message boxes are triggered correctly - obviously this is just a double-check that the right code is firing, which i will remove in the final version.

NB: it seems NOT to be essential to include quotation marks around the form name in the IsLoaded function.
 
is this sorted now

i think its the same point rich just made

you are passing to isloaded the form itself, but the function you have wants a string


------------
what are you trying to do generally - can you explain?

this is sorted now, yes :) thanks to everyone who contributed :)
 
also, i had to force the checkbox to be unchecked for the test to work and display the correct report sections/controls (when i first open the form) - as i think the checkbox has a null state (even though the "triple state" property is set to 'no', and i think this because once i check and uncheck the checkbox it works fine.
 
Just a FYI-

There's a cognitive dissonance between Jet's Yes/No data type which cannot accept a Null value and Access control which can accept Null. Just so you know.
 
Use the NZ function to deal with the problem of null checkboxes
 
yes, that's a good point too, Rich.

however, i've discovered that i actually must have the checkbox at the 'checked' state otherwise (when the detail section is made invisible if the checkbox is left unchecked) the counts i've developed in the different groupings etc return "0" if the detail is hidden! what a nuisance! anyone know a work-around? it'd be interesting for me to do a bit of research on that...

(edit: that is, i'm forcing my checkbox to be 'checked' on form open until i find a workaround for the detail hiddind issue)
 

Users who are viewing this thread

Back
Top Bottom