"You can't assign a value to this object", Access report

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
 
R

Rebecca Riordan

What you want to do is set the default value, rather than the control
source. But you should also be aware that this isn't a terribly robust
implementation -- what will you do if somebody spills coffee on their copy
and wants a duplicate?

HTH

--
Rebecca Riordan, MVP

Designing Relational Database Systems
Microsoft SQL Server 2000 Programming Step by Step
Microsoft ADO.NET Step by Step

http://www.microsoft.com/mspress

Blessed are they who can laugh at themselves,
for they shall never cease to be amused...
 

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