Dear Sir,
I have 10 unbound textboxes with the Tag Name "LoopID" in my report. I have to display the "PatientNumbers" field from the table tblPatient in those text boxes. Below is my code. When I run the report, I get the error message: Run-time error '2448.' You can't assign value to this object and the code "Ctl.Value = rst!LCANumber" is highlighted. Please let me know what I am doing wrong.
Thank you.
Private Sub Report_Current()
Dim strSql As String
Dim dbs As Database
Dim rst As Recordset
Dim x As Integer
Dim Ctl As Control
strSql = "Select PatientNumber from tblPatient"
Set dbs = CurrentDb()
Set rst = db.OpenRecordset(strSql)
With rst
.MoveFirst
Do While Not rst.EOF
For Each Ctl In Reports!rptPatient.Controls
If Ctl.ControlType = acTextBox Then
If Ctl.Tag = "LoopID" Then
Ctl.Value = rst!PatientNumber
Exit For
End If
End If
Next Ctl
.MoveNext
Loop
.Close
End With
End Sub
I have 10 unbound textboxes with the Tag Name "LoopID" in my report. I have to display the "PatientNumbers" field from the table tblPatient in those text boxes. Below is my code. When I run the report, I get the error message: Run-time error '2448.' You can't assign value to this object and the code "Ctl.Value = rst!LCANumber" is highlighted. Please let me know what I am doing wrong.
Thank you.
Private Sub Report_Current()
Dim strSql As String
Dim dbs As Database
Dim rst As Recordset
Dim x As Integer
Dim Ctl As Control
strSql = "Select PatientNumber from tblPatient"
Set dbs = CurrentDb()
Set rst = db.OpenRecordset(strSql)
With rst
.MoveFirst
Do While Not rst.EOF
For Each Ctl In Reports!rptPatient.Controls
If Ctl.ControlType = acTextBox Then
If Ctl.Tag = "LoopID" Then
Ctl.Value = rst!PatientNumber
Exit For
End If
End If
Next Ctl
.MoveNext
Loop
.Close
End With
End Sub