Call Syntax

  • Thread starter Thread starter Al Camp
  • Start date Start date
A

Al Camp

I'd like to Call a Public Sub from another form.
From form frmLoomSchedule I'd want to invoke a Public Sub called
Public Sub RequerySubform()
that exists in the module of a subform...
Forms!frmOrderEntry!frmOrdersLoomScheduleSub
which is open at the time, and the path is correct.

I've tried...
Call Forms!frmOrderEntry!frmOrdersLoomScheduleSub.RequerySubform
(yields "(" expected intellisense error)

Forms!frmOrderEntry!frmOrdersLoomScheduleSub.RequerySubform
(yields "can't find the object frmOrdersLoomScheduleSub...)

Forms!frmOrderEntry!frmOrdersLoomScheduleSub.Form.RequerySubform
(yields "can't find the object frmOrdersLoomScheduleSub...)

Forms("frmOrderEntry!frmOrdersLoomScheduleSub").RequerySubform

I found many hits on this in Google Access newsgroups, but they all seem to
indicate that one or more of these formats should work.

What's wrong with my syntax. Thanks for any help.
Al Camp
 
Try

Call Forms("frmOrderEntry").frmOrdersLoomSchedule.Form.RequerySubform

This assumes that the name of the control on frmOrderEntry that contains the
subform frmOrdersLoomSchedule is actually named frmOrdersLoomSchedule. This
should be the case if you created the subform by dragging form
frmOrdersLoomSchedule onto from frmOrderEntry, but if you actually created a
subform control from the toolbar, it's probably going to be named Child0 or
something like that, in which case you'd want:

Call Forms("frmOrderEntry").Child0.Form.RequerySubform

(I always rename the subform container to be different than the form that it
contains, just to avoid confusion.)
 
Douglas,
Thanks for the reply, but no luck yet.
Subform control name = frmOrdersLoomScheduleSub.
Subform Source Object = frmOrdersLoomScheduleSub.

Both caused a "R/T Error 2465 - Application Defined Error od Object Defined
Error"

This Call is made from a subform...
Forms!frmLoomSchedule!frmLoomScheduleSub.
It triggers on the Exit button that closes frmLoomSchedule. As I originally
came to this form from frmOrderEntry, I set the frmLoomSchedule OpenArgs to
"FromOrders"

'...some IF code here...
Else
Refresh
If OpenArgs = "FromOrders" Then
Call
Forms("frmOrderEntry").frmOrdersLoomScheduleSub.Form.RequerySubform
End If
DoCmd.Close acForm, "frmLoomSchedule"
End If

This caused a "R/T Error 2465 - Application Defined Error od Object
Defined Error"

Here's what I also tried. I replaced the Public Sub RequerySubform with
just a simple message box, to make sure that the procedure I was "calling"
wasn't introducing any errors. The Call statement failed exactly the same
as before. So, there must be a problem with how I'm calling that sub.

I'm really at a loss as to why this won't work.

Thanks for the help...
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions
 
Odd. It worked for me, so perhaps there's some sort of corruption in your
database.

Any particular reason why the sub has to be in the subform?
 
Douglas,
You know, I thought of that, and compacted and repaired the mdb a couple
of times. Worth a shot.
What gets me is that I can't even "Call" a simple msgbox on that external
subform.
Odd. It worked for me
As I said, I found many hits in the ngs on this subject, but none of the
varied solutions work.
Any particular reason why the sub has to be in the subform?
Public Sub RequerySubform is from Leban's code. It requeries the subform
without causing any "jump", and it works well "locally" on the subform
itself.

I wrote...I mispoke. The Exit button on the "calling form" is on the main form, so
the Call is from MainForm to external subform.

Thanks a lot for giving it a shot. I'll just have to gut it out from here,
or try some other "work around".

Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions
 
Douglas J. Steele said:
(I always rename the subform container to be different than the form
that it contains, just to avoid confusion.)

Funny, I always name them the same except when I'm using multiple
subform controls displaying the same source object. To avoid confusion.
:-)
 
Back
Top