I have the following onCurrent code, for a form, so I can set 2 unbound text boxes to create a dynamic string, for the user. The code checks if the form is on a new record. If so, it makes the 2 unbound text boxes be blank, so they don't show #Name errors. That is what you see, if none of the pieces that are used in the formulas for the text boxes, have any value to them.
I get an error, when I try to load the form. It loads on the last record, which means it's not a new record.
Error:
run-time error '2448': you can't assign a value to this object
Anyone know what I'm doing wrong?
I get an error, when I try to load the form. It loads on the last record, which means it's not a new record.
Code:
Private Sub Form_Current()
If Me.NewRecord Then
Me.txtBox1.Value = ""
Me.txtBox2.Value = ""
Else
Me.txtBox1.Value = DLookup("MyType", "tblMyType", "ID= " & Nz([FKMyType], 0)) & " " & DLookup("MyCategory", "tblMyCategory", "ID= " & Nz([FKMyCategory], 0)) & " " & Nz([MyLocation], 0)
Me.txtBox2.Value = "ABC" & Format([ID], "0000")
End If
End Sub
Error:
run-time error '2448': you can't assign a value to this object
Anyone know what I'm doing wrong?