managing textbox value while formatting the report

G

Guest

hello,
from some other post I have read that textbox value can be changed throught
the format event of a report section.
If this is true, why this code wont work?
<code>
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Application.Echo False
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
Dim ctl As Control
rst.Open "tblabs", CurrentProject.Connection, adOpenStatic, adLockReadOnly
Dim i As Integer
With rst
.Filter = "strpazid='" & Forms("totali").codfisc & "'"
For Each ctl In Reports("reportabs2").Controls
If ctl.Name Like "q*" Then
Select Case .Fields(ctl.Name)
Case Is = 1
ctl.Value = "SI"
Case Is = 0
ctl.Value = "NO"
Case Is = 9
ctl.Value = "N/A"
End Select
End If
Next ctl
End With
</code>

It stops on whene trying to write value for the first ctl saying "You cannot
assign value to this object".

thanks
Rocco
 
M

Marshall Barton

rocco said:
from some other post I have read that textbox value can be changed throught
the format event of a report section.
If this is true, why this code wont work?
<code>
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Application.Echo False
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
Dim ctl As Control
rst.Open "tblabs", CurrentProject.Connection, adOpenStatic, adLockReadOnly
Dim i As Integer
With rst
.Filter = "strpazid='" & Forms("totali").codfisc & "'"
For Each ctl In Reports("reportabs2").Controls
If ctl.Name Like "q*" Then
Select Case .Fields(ctl.Name)
Case Is = 1
ctl.Value = "SI"
Case Is = 0
ctl.Value = "NO"
Case Is = 9
ctl.Value = "N/A"
End Select
End If
Next ctl
End With
</code>

It stops on whene trying to write value for the first ctl saying "You cannot
assign value to this object".


That message implies that the control does not have a value
property (e.g. label) or that the control is bound to a
field or expression. Make sure that that all the "q"
controls are unbound text boxes.
 

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