Report Run-Time Error

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
 
D

Duane Hookom

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
 
G

Guest

Duane,

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

Cheers,


Greg.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top