I have a report with the following unbound text boxes in the detail section.
TextNm and Text0-Text5.
I am trying to assign values to each using the following code. However each assignment statements (Me!TextNm = rst.Fields(i).Value) produces the following error "You can't assign a value to this object"
Any help would be appreciated.
Thanks
Private Sub Report_Open(Cancel As Integer)
Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim i As Integer
Dim j As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("select * from qxtbContribByYear")
rst.MoveFirst
j = -1
i = 0
For i = 0 To rst.Fields.Count - 1
If rst.Fields(i).name Like "*nm" Then
Me!TextNm = rst.Fields(i).Value
GoTo skip_it
End If
j = j + 1
Select Case j
Case 0
Me.Text0 = rst.Fields(i).Value
Case 1
Me.Text1 = rst.Fields(i).Value
Case 2
Me.Text2 = rst.Fields(i).Value
Case 3
Me.Text3 = rst.Fields(i).Value
Case 4
Me.Text4 = rst.Fields(i).Value
Case 5
Me.Text5 = rst.Fields(i).Value
End Select
skip_it:
Next
rst.Clone
Set rst = Nothing
End Sub
TextNm and Text0-Text5.
I am trying to assign values to each using the following code. However each assignment statements (Me!TextNm = rst.Fields(i).Value) produces the following error "You can't assign a value to this object"
Any help would be appreciated.
Thanks
Private Sub Report_Open(Cancel As Integer)
Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim i As Integer
Dim j As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("select * from qxtbContribByYear")
rst.MoveFirst
j = -1
i = 0
For i = 0 To rst.Fields.Count - 1
If rst.Fields(i).name Like "*nm" Then
Me!TextNm = rst.Fields(i).Value
GoTo skip_it
End If
j = j + 1
Select Case j
Case 0
Me.Text0 = rst.Fields(i).Value
Case 1
Me.Text1 = rst.Fields(i).Value
Case 2
Me.Text2 = rst.Fields(i).Value
Case 3
Me.Text3 = rst.Fields(i).Value
Case 4
Me.Text4 = rst.Fields(i).Value
Case 5
Me.Text5 = rst.Fields(i).Value
End Select
skip_it:
Next
rst.Clone
Set rst = Nothing
End Sub