"You can't assign a value to this object"

J

Jen

In a reports footer I have a nonvisible textbox named NumCopiesPrinted with
controlsource "=0" in the report footer on a report. I also have this label
"WhichCopy". The idea is that a different text is shown in the label
depending on which copy is being printed (number in the hidden textbox named
"NumCopiesPrinted"), (users can choose how many copies they want to print
from the main form from a combobox, this works ok, code for this at the
bottom of this message).

In the report footers onFormat event I have:

Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)

Me.NumCopiesPrinted = Me.NumCopiesPrinted + 1 <--THIS LINE IS CAUSING
THE ERROR

If FormatCount = 1 Then
Select Case NumCopies
Case 1
Me.WhichCopy.Visible = False
Case 2
Me.WhichCopy.Caption = "Own Copy"
Me.WhichCopy.Visible = True
Case 3
Me.WhichCopy.Caption = "Accounting Copy"
Me.WhichCopy.Visible = True
Case 4
Me.WhichCopy.Caption = "Supervisor Copy"
Me.WhichCopy.Visible = True

End Select
End If
End Sub

...which causes the "You can't assign a value to this object" error when I
hit the print button. The textbox value NumCopiesPrinted can't be changed?
Why/ any way around this?

Jen

...and the printout code:

Private Sub utskrift_Click()
On Error GoTo Err_utskrift_Click

Dim stDocName As String

stDocName = "Faktura"
DoCmd.OpenReport stDocName, acPreview, "",
"[fakturanr]=[Forms]![fakturainmatning]![fakturanr]"

DoCmd.PrintOut , , , , Me!kopiaval, -1
DoCmd.Close acReport, stDocName, acSaveNo
Exit_utskrift_Click:
Exit Sub

Err_utskrift_Click:
MsgBox err.Description
Resume Exit_utskrift_Click

End Sub
 

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

Top