Stumper - Procedure Call can't find form

sphere_monk

Registered User.
Local time
Today, 12:06
Joined
Nov 18, 2002
Messages
62
Hi Everyone,

I have a combo box on a subform from which I call a couple Public Subs in its AfterUpdate Event. None of the following calls recognize the forms that I'm trying to pass to them. The calls are as follows:

Call DisableFields(Forms!frmInventoryTemp)
Call EnableBasedOnType(Forms!frmInventoryTemp)​

and the first couple lines of the Public Subs themselves are:

Public Sub DisableFields(frm As Form)
On Error GoTo Err_DisableFields

Dim ctl As Control
Dim ctltype As String
etc.​

and

Public Sub EnableBasedOnType(frm As Form)
On Error GoTo Err_EnableBasedOnType

' MsgBox ("Running EnableBasedOnType on " & frm.Name)

Dim rst As New ADODB.Recordset
Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
etc.​

The message I'm receiving when the Calls run is:

"Workorder System can't find the form "frmInventoryTemp" referred to in a macro expression or Visual Basic Code"​

The funny thing is that I have another form set up exactly as this form (with a subform and a combo box calling the procedures from it's AfterUpdate event) and they work. If I copy the Call statements directly from that code that works into the afterupdate event of the other combo box on the other form they don't work, even if I'm passing the same form!

I'm completely lost as to why this could happen. The forms are in the same database. Could someone please help me?
 
Last edited:
Sphere,

Are you sure that the forms are OPEN when the code is executed?

They have to be.

Wayne
 
Thank you Wayne and Larry for your posts.

Wayne,

The form is open. I'm getting the message when testing the form and after I select an InventoryID from the combo box on the subform. The AfterUpdate event is firing off my code and popping up the message I showed earlier.

Larry,

Thanks for the link to the Form/Subform syntax page. That's the best summary of syntax I've seen. I've posted it to my wall since I'm frequently getting the syntax wrong in that area:D .

I don't think it applies in this case though. I'm not referring to the form or any object on the form, I'm actually just passing the form to the sub procedure, and I don't think the syntax of the Call statement changes respective to where the Call statement is issued. I think the Sub needs the formal name of the form. (eg. Forms!<formname>)

Of course, maybe this is where I'm wrong. Is there anyone that could verify this?

Also, the syntax works on the other form. It's almost like because I'm issuing it from a different form, the form itself either doesn't see or doesn't have rights to the list of forms. I see the form in the form list, I can edit it, I can run it and I can even call it from the subform of the other form, but as soon as I try to call it from this other form, it says it doesn't exist.
 
Well, I found a workaround for the problem. The following statement works:

Call Disablefields(Me)

It still doesn't make sense to me why the Forms!<formname> will not work. If anyone has an idea why, I would like to hear it.

Thanks, Larry, for pointing me in the right direction. All those Me's on that syntax sheet inspired "Me" :o
 

Users who are viewing this thread

Back
Top Bottom