Error 2448 - Cannot assign value to Textbox

Zillandi

New member
Local time
Yesterday, 17:17
Joined
Apr 4, 2016
Messages
3
Initially I solved this by making sure there was a blank row when the table was created so it wasn't trying to set the textbox with a null value... and it worked :D... but now it doesn't :mad: The line in red text is the offending code - any thoughts?

Code:
 Private Sub Form_Load()
    'Dim t As TextBox
    tsPage = 1
    ln = Me.Controls.Count
    
    oa = Split(Me.OpenArgs, ";")
    oa0 = oa(0)
    oa1 = oa(1)
    oa2 = oa(2)
    
    'Determine number of days in month oa2 and the first day of the week
    daysInMonth = DateSerial(Year(oa2), Month(oa2) + 1, 1) - DateSerial(Year(oa2), Month(oa2), 1)
    firstWeekDay = Weekday(oa2, vbSunday)
    Set db = CurrentDb
    Set rs1 = CurrentDb.OpenRecordset(oa0 & "_1")
    Set rs2 = CurrentDb.OpenRecordset(oa0 & "_2")
    
    curDay = 1
    For i = 1 To 7
        If i >= firstWeekDay Then
            Me.Controls("lblDay" & i).Caption = Month(oa2) & "/" & curDay & "/" & Year(oa2)
            
            For j = 7 To 19
                MsgBox rs1.Fields(curDay & "0" & j)
                If j < 10 Then
                    [COLOR=red]Me.Controls("tb" & i & j) = rs1.Fields(curDay & "0" & j)
[/COLOR]              Else
                    Me.Controls("tb" & i & j) = rs1.Fields(curDay & j)
                End If
            Next j
            
            curDay = curDay + 1
        Else
            For j = 7 To 19
                Me.Controls("tb" & i & j).Enabled = False
            Next j
        End If
    Next i
    
    For Each c In Me.Controls
        If TypeOf c Is TextBox Then
            If c.Name = "tbDate" Or c.Name = "tbEmpName" Or c.Name = "tbOa0" Or c.Name = "tbOa1" Or c.Name = "tbOa2" Or c.Name = "tbtsPage" Then
            Else
                If inner = 20 Then
                    inner = 7
                    outer = outer + 1
                End If
                
                c.OnGotFocus = "=gotFocus('" & c.Name & "')"
                c.OnLostFocus = "=lostFocus('" & c.Name & "')"
                c.OnClick = "=click('" & c.Name & "')"
                c.afterUpdate = "=update('" & c.Name & "')"
                
                inner = inner + 1
            End If
        End If
    Next
    
    'Assign values to employee name and date
    oa2 = MonthName(Month(oa2)) & " " & Year(oa2)
    tbEmpName.value = oa1
    tbDate.value = oa2
End Sub
 
I presume the "offending code" happens at run time.

You do have a control with the name that is being generated by your code?

What happens if you insert the following line
before your offending code?
Code:
debug.print Me.Controls("tb" & i & j)
 
debug.print Me.Controls("tb" & I & j) results in Error 2424: The expression you entered has a field, control, or property name that [Table Name]: Employee and Client Database can't find

I have also tried directly referencing on of the textboxes and still end up with error 2448.

The text that should be pulled from the record set is a single blank space
 
I just figured it out... I had rebuilt this code earlier today in such a way that the textboxes no longer required a control source. However, since the previous build DID require control sources, all of the textboxes still had their control source property set. Simply erasing that property from all textboxes has resolved the issue.
 

Users who are viewing this thread

Back
Top Bottom