Re: Cannot assign a Value
- From: "Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx>
- Date: Fri, 13 Oct 2006 13:35:03 -0400
The Open event is too early: not all of the controls are instantiated until
the Load event.
Realistically, since the Open event allows cancellation, and the Load event
doesn't, it makes sense to put any code that determines whether or not to
display the form in the Open event, and any code that initializes or formats
the form in its Load event.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Sprinks" <Sprinks@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2BC6C12D-F0C7-42F1-92A8-337179E93D69@xxxxxxxxxxxxxxxx
Klatuu,
Thank you; it works. But, in the interest of "learning how to fish", can
you tell me why?
Thanks.
Sprinks
"Klatuu" wrote:
Move your code from the Open event to the Load event.
"Sprinks" wrote:
I've placed a command button on a continuous form to open up a form in
which
to add a Note to the current project. I'm trying to initialize the
record
with the StaffID, ProjectNumber, and Status, but I'm receiving the
error
message 2448: "You can't assign a value to this object." I've
double-checked the form and control names--I don't think there are any
typos.
Can anyone explain it?
Sprinks
' Command button code
Private Sub cmdNote_Click()
On Error GoTo Err_Handler
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "ProjectNotes"
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd
Err_Exit:
Exit Sub
Err_Handler:
MsgBox "The following error has occurred. Please contact the
system
administrator." & _
vbCrLf & vbCrLf & Err.Number & vbCrLf & Err.Description,
vbOKOnly,
"Runtime Error"
Resume Err_Exit
End Sub
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Handler
Me![txtStaffID] = Forms![Time***]![txtStaffID]
Me![txtStatusID] = 2
Me![cboProjectNumber] =
Forms!Timesheet!TimeSheetDetail.Form![cboProjectNumber]
Err_Exit:
Exit Sub
Err_Handler:
MsgBox "The following error has occurred. Please contact the
system
administrator." & _
vbCrLf & vbCrLf & Err.Number & vbCrLf & Err.Description,
vbOKOnly,
"Runtime Error"
Resume Err_Exit
End Sub
.
- References:
- RE: Cannot assign a Value
- From: Sprinks
- RE: Cannot assign a Value
- Prev by Date: RE: Not In List - carrying over data to form
- Next by Date: Re: Determining Where Cursor Was B4 Pushing Cmd Button
- Previous by thread: RE: Cannot assign a Value
- Next by thread: RE: Desperately dying on simple problem-Field not on Control Sourc
- Index(es):