Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

cancel report if subreport has no data

Discussion in 'Information Technology' started by hughess7, Oct 28, 2005.

  1. hughess7

    hughess7
    Expand Collapse
    Guest

    I can not use the no data event on my main report to cancel opening as it
    always has some data. If my subreport has no data though I would like the
    main report to cancel opening.

    Tried the following but I get error 2455, Invalid reference to the property
    form/report

    If Me![Expenses Weekly].Report.HasData = False Then
    Cancel = True
    Msg = "No Expenses for " & Forms![frm resource menu]![txtSpecialist] & _
    " w/e " & Forms![frm resource menu]![StartDate] + 4
    MsgBox Msg, vbInformation
    End If

    Can anyone help with this please?

    Thanks
    Sue
     
  2. Loading...


  3. Ofer

    Ofer
    Expand Collapse
    Guest

    Use the code on the OnActivate event of the main report

    If Me![Expenses Weekly].Report.HasData = False Then
    Msg = "No Expenses for " & Forms![frm resource menu]![txtSpecialist] & _
    " w/e " & Forms![frm resource menu]![StartDate] + 4
    MsgBox Msg, vbInformation
    DoCmd.Close acReport, "Report Name"
    End If

    --
    If I answered your question, please mark it as an answer. That way, it will
    stay saved for a longer time, so other can benifit from it.

    Good luck



    "hughess7" wrote:

    > I can not use the no data event on my main report to cancel opening as it
    > always has some data. If my subreport has no data though I would like the
    > main report to cancel opening.
    >
    > Tried the following but I get error 2455, Invalid reference to the property
    > form/report
    >
    > If Me![Expenses Weekly].Report.HasData = False Then
    > Cancel = True
    > Msg = "No Expenses for " & Forms![frm resource menu]![txtSpecialist] & _
    > " w/e " & Forms![frm resource menu]![StartDate] + 4
    > MsgBox Msg, vbInformation
    > End If
    >
    > Can anyone help with this please?
    >
    > Thanks
    > Sue
     
  4. hughess7

    hughess7
    Expand Collapse
    Guest

    Thanks that sorted it!

    Sue


    "Ofer" wrote:

    > Use the code on the OnActivate event of the main report
    >
    > If Me![Expenses Weekly].Report.HasData = False Then
    > Msg = "No Expenses for " & Forms![frm resource menu]![txtSpecialist] & _
    > " w/e " & Forms![frm resource menu]![StartDate] + 4
    > MsgBox Msg, vbInformation
    > DoCmd.Close acReport, "Report Name"
    > End If
    >
    > --
    > If I answered your question, please mark it as an answer. That way, it will
    > stay saved for a longer time, so other can benifit from it.
    >
    > Good luck
    >
    >
    >
    > "hughess7" wrote:
    >
    > > I can not use the no data event on my main report to cancel opening as it
    > > always has some data. If my subreport has no data though I would like the
    > > main report to cancel opening.
    > >
    > > Tried the following but I get error 2455, Invalid reference to the property
    > > form/report
    > >
    > > If Me![Expenses Weekly].Report.HasData = False Then
    > > Cancel = True
    > > Msg = "No Expenses for " & Forms![frm resource menu]![txtSpecialist] & _
    > > " w/e " & Forms![frm resource menu]![StartDate] + 4
    > > MsgBox Msg, vbInformation
    > > End If
    > >
    > > Can anyone help with this please?
    > >
    > > Thanks
    > > Sue
     

Share This Page