Hi Everyone,
I'm having some difficulty setting values for some unbound text boxes on a report of mine using VBA. Doing a quick search of various Access programming sites, everyone seems to be suggesting the straightforward code: Me.myTextBox.Value = x. Unfortunately when I use this plain and simple approach I receive the dreaded run time error 2448 - 'You can't assign a value to this object'. The code I am using is posted below and I would appreciate any thoughts any of you may have.
Code:
Private Sub Report_Open(Cancel As Integer)
Dim myARPTID As Integer, strSQL As String, strRST As String, rst As DAO.Recordset, AccTitle(5) As String, AccType(3) As String
Dim AccSum(5) As String, DateAcc(5) As Date, i As Integer
'Getting the specific Annual Report ID for selecting the list of accomplishments
myARPTID = Forms![ARPT-CA].fARPTID
Debug.Print myARPTID
strSQL = "SELECT PartInfo.[Participant Name], ARPT.AProfGoal, PartInfo.Cohort, PartInfo.[Sponsoring Service]," & _
" PartInfo.[STEM Discipline], ARPT.APRTID" & _
" FROM PartInfo INNER JOIN ARPT ON PartInfo.[Smart Id] = ARPT.SMARTID" & _
" WHERE (((ARPT.APRTID)=" & myARPTID & "));"
Me.RecordSource = strSQL
' Getting any accomplishments for this participant
strRST = "SELECT ARACC.AccTitle, ARACC.DateAcc, ARACC.AccType, ARACC.AccSum" & _
" FROM ARPT INNER JOIN ARACC ON ARPT.APRTID = ARACC.ARPTID" & _
" WHERE (((ARPT.APRTID)=" & myARPTID & "))"
Set rst = CurrentDb.OpenRecordset(strRST)
' Looping through potential accomplishments and assigning them to arrays
i = 1
Do Until rst.EOF
AccTitle(i) = rst![AccTitle]
DateAcc(i) = rst![DateAcc]
AccType(i) = rst![AccType]
AccSum(i) = rst![AccSum]
i = i + 1
rst.MoveNext
Loop
' Accomplishment 1
Me.txtAcc1.SetFocus
Me.txtAcc1.Value = AccSum(1)
Me.txtAccTitle1.Value = AccTitle(1)
Me.txtType1.Value = AccType(1)
' Accomplishment 2
Me.txtAcc2.Text = AccSum(2)
Me.txtAccTitle2.Text = AccTitle(2)
Me.txtType2.Text = AccType(2)
' Accomplishment 3
Me.txtAcc3.Text = AccSum(3)
Me.txtAccTitle3.Text = AccTitle(3)
Me.txtType3.Text = AccType(3)
End Sub