Full Version: Calling sub when form is opened
UtterAccess Forums > Microsoft® Access > Access Forms
I have a button on a form that opens another form to a new record, populates three controls on the newly opened form with data from the first form, and then I want it to call an AfterUpdate procedure for the last control it populated. That is where I get an error message. The VB code is below ...
Private Sub btnReqChange_Click()
DoCmd.OpenForm "frmRequestClasses", , , , acFormAdd

'populate form with data for the CRN from the Class Schedule form
Forms!frmRequestClasses!RequestType = "Change"
Forms!frmRequestClasses!TermCode = Me!Term
Forms!frmRequestClasses!CRN = Me!CRN
Call Forms.frmRequestClasses.CRN_AfterUpdate

End Sub
The Call line above returns an "Item not found in this collection" error, but CRN_AfterUpdate() does exist in frmRequestClasses and works fine if I update the field directly.
Any ideas?
I found my problem. A table field referenced in frmRequestClasses.CRN_AfterUpdate had been eliminated from the table. I removed the reference to it and all works well.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.