Report Run-Time Error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

Any assistance will be appreciated.

I have a subform "frmpayments" within a form "frminvoice" and a command
button opening a report "rptInvoice", the problem is if there is no payment
or record on the "frmpayments" when i click on the command button i get a
Run-Time Error '2427'.

It appears there must be a record in the subform "frmPayments" OR i'm hoping
there maybe an alternative.

The Run-Time Error refers to the following when i click on Debug, which of
course works perfectly when there's a record in subfrom "frmPayments".

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Debtor.Value = 2 Then
Me.AccountsName.Visible = False
Me.AccountsAddress.Visible = False
Me.AccountsSuburb.Visible = False
Me.InvoiceOwner.Visible = True
Me.InvoiceAddress.Visible = True
Me.InvoiceSuburb.Visible = True
Else
Me.AccountsName.Visible = True
Me.AccountsAddress.Visible = True
Me.AccountsSuburb.Visible = True
Me.InvoiceOwner.Visible = False
Me.InvoiceAddress.Visible = False
Me.InvoiceSuburb.Visible = False
End If
End Sub
 
You might try wrap your code in HasData to see


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.HasData Then
If Me.Debtor.Value = 2 Then
Me.AccountsName.Visible = False
Me.AccountsAddress.Visible = False
Me.AccountsSuburb.Visible = False
Me.InvoiceOwner.Visible = True
Me.InvoiceAddress.Visible = True
Me.InvoiceSuburb.Visible = True
Else
Me.AccountsName.Visible = True
Me.AccountsAddress.Visible = True
Me.AccountsSuburb.Visible = True
Me.InvoiceOwner.Visible = False
Me.InvoiceAddress.Visible = False
Me.InvoiceSuburb.Visible = False
End If
End If
End Sub
 
Duane,

Thanks for that! Problem solved and it also solved a similar problem in
another area of my database.

Cheers,


Greg.
 
Back
Top