473,503 Members | 722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to run a subroutine in a sub-form from the parent

I have a form that was a stand-alone form which I converted into a sub-form.
On the original form was a close button which did a lot more than just
close. It ran update and append queries (after a VBYesNo in a MsgBox) on
the data in what is now the sub-form. Then it closed. It also runs
functions local to that sub-form. I'd like to just keep everything the way
it is and somehow just call the code from the parent form's new close
button. Here's what I already tried:

"Forms!subFrmEnterGrades!cmdSave_Click"

But I got an error. Access couldn't find the form, though it was right
there in the main form! I was looking right at it. Is there another way to
skin this cat, or do I have to start from scratch?
Nov 13 '05 #1
5 9959
Subforms, even when the main form is open, are not part of the Forms
collection.
Try something like this:
Forms!subFrmEnterGrades.Form!cmdSave_Click
Or
Form_subFrmEnterGrades!cmdSave_Click

HTH
- Turtle

"Richard Hollenbeck" <ri****************@verizon.net> wrote in message
news:NmU4d.12229$464.9727@trnddc01...
I have a form that was a stand-alone form which I converted into a sub-form. On the original form was a close button which did a lot more than just
close. It ran update and append queries (after a VBYesNo in a MsgBox) on
the data in what is now the sub-form. Then it closed. It also runs
functions local to that sub-form. I'd like to just keep everything the way it is and somehow just call the code from the parent form's new close
button. Here's what I already tried:

"Forms!subFrmEnterGrades!cmdSave_Click"

But I got an error. Access couldn't find the form, though it was right
there in the main form! I was looking right at it. Is there another way to skin this cat, or do I have to start from scratch?

Nov 13 '05 #2
Oh, and make sure that you change cmdSave_Click to Public, so that it can be
seen from "outside".

- Turtle

"Richard Hollenbeck" <ri****************@verizon.net> wrote in message
news:NmU4d.12229$464.9727@trnddc01...
I have a form that was a stand-alone form which I converted into a sub-form. On the original form was a close button which did a lot more than just
close. It ran update and append queries (after a VBYesNo in a MsgBox) on
the data in what is now the sub-form. Then it closed. It also runs
functions local to that sub-form. I'd like to just keep everything the way it is and somehow just call the code from the parent form's new close
button. Here's what I already tried:

"Forms!subFrmEnterGrades!cmdSave_Click"

But I got an error. Access couldn't find the form, though it was right
there in the main form! I was looking right at it. Is there another way to skin this cat, or do I have to start from scratch?

Nov 13 '05 #3
Thanks for your help.
I tried both your suggestions and both times got the prompt: "Expected:
=" whatever that means. I double checked the spelling and everything else
is as you gave it to me. Is there any other suggestion?

"MacDermott" <ma********@nospam.com> wrote in message
news:5P***************@newsread3.news.atl.earthlin k.net...
Oh, and make sure that you change cmdSave_Click to Public, so that it can be seen from "outside".

- Turtle

"Richard Hollenbeck" <ri****************@verizon.net> wrote in message
news:NmU4d.12229$464.9727@trnddc01...
I have a form that was a stand-alone form which I converted into a sub-form.
On the original form was a close button which did a lot more than just
close. It ran update and append queries (after a VBYesNo in a MsgBox) on the data in what is now the sub-form. Then it closed. It also runs
functions local to that sub-form. I'd like to just keep everything the

way
it is and somehow just call the code from the parent form's new close
button. Here's what I already tried:

"Forms!subFrmEnterGrades!cmdSave_Click"

But I got an error. Access couldn't find the form, though it was right
there in the main form! I was looking right at it. Is there another

way to
skin this cat, or do I have to start from scratch?


Nov 13 '05 #4
The form displayed in a Subform Control is not Open, and therefore not in
the Forms collection. It exists and is addressable as the .Form property of
the Subform Control.

This code in "frmOrders"

Private Sub Command10_Click()
Me!sbfCustomers.Form.RunFromOutside
End Sub

caused the following code in the Form ("frmCustomers" but name is
immaterial) embedded in the Subform Control ("sbfCustomers") to execute.
This is a form-level procedure -- you may have to change your event
procedure from Private to Public.

Public Sub RunFromOutside()
MsgBox "The code in frmCustomers ran", vbOKOnly, "Test running code
from outside"
End Sub

Good luck with your project.

Larry Linson
Microsoft Access MVP

"Richard Hollenbeck" <ri****************@verizon.net> wrote in message
news:NmU4d.12229$464.9727@trnddc01...
I have a form that was a stand-alone form which I converted into a sub-form. On the original form was a close button which did a lot more than just
close. It ran update and append queries (after a VBYesNo in a MsgBox) on
the data in what is now the sub-form. Then it closed. It also runs
functions local to that sub-form. I'd like to just keep everything the way it is and somehow just call the code from the parent form's new close
button. Here's what I already tried:

"Forms!subFrmEnterGrades!cmdSave_Click"

But I got an error. Access couldn't find the form, though it was right
there in the main form! I was looking right at it. Is there another way to skin this cat, or do I have to start from scratch?

Nov 13 '05 #5
You might try Larry's suggestion of using dots instead of bangs.

"Richard Hollenbeck" <ri****************@verizon.net> wrote in message
news:8dV4d.12250$464.2478@trnddc01...
Thanks for your help.
I tried both your suggestions and both times got the prompt: "Expected: =" whatever that means. I double checked the spelling and everything else
is as you gave it to me. Is there any other suggestion?

"MacDermott" <ma********@nospam.com> wrote in message
news:5P***************@newsread3.news.atl.earthlin k.net...
Oh, and make sure that you change cmdSave_Click to Public, so that it can
be
seen from "outside".

- Turtle

"Richard Hollenbeck" <ri****************@verizon.net> wrote in message
news:NmU4d.12229$464.9727@trnddc01...
I have a form that was a stand-alone form which I converted into a

sub-form.
On the original form was a close button which did a lot more than just
close. It ran update and append queries (after a VBYesNo in a MsgBox) on the data in what is now the sub-form. Then it closed. It also runs
functions local to that sub-form. I'd like to just keep everything the way
it is and somehow just call the code from the parent form's new close
button. Here's what I already tried:

"Forms!subFrmEnterGrades!cmdSave_Click"

But I got an error. Access couldn't find the form, though it was

right there in the main form! I was looking right at it. Is there another

way
to
skin this cat, or do I have to start from scratch?



Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2256
by: Bill | last post by:
I've got a subroutine, defined as Private, takes two parameters, that is called lots of times from different ASP scripts. I need specific error handling when it is called from only one particular...
2
1444
by: Redeem | last post by:
is Page_Load Subroutine a system defined soubroutine meaning it isn't user defined? I assume any code I place under that routine name will automatically load when web page is run is it ? ...
7
9542
by: Richard Grant | last post by:
Hi. In c/C++ i can pass the address of a subroutine to another subroutine as an actual parameter How do I do that in VB .NET What should be the syntax for a parameter to receive the address of a...
2
1434
by: singlal | last post by:
Hi, my question was not getting any attention because it moved to 2nd page; so posting it again. Sorry for any inconvenience but I need to get it resolved fast. Need your help! ...
5
5844
by: gabba | last post by:
Hi, is it possible to call a subroutine (or a function) using variable name? Sub a() Response.write("sub a") End sub Sub b() Response.write("sub b") End sub
2
1668
by: victor.buga | last post by:
Hi, Could somebody please guide me how to retrieve the subroutine that's on the server, and using javascript tell the server to invoke that subroutine. Everything is in the same ".asp" page. ...
5
2170
by: dancer | last post by:
Using ASP.net 1.1 and VB Is it possible to declare variables in their own subroutine? I had my DIM statements within a sub that worked just fine. I wanted to be able to use them in another...
1
1529
by: johnperl | last post by:
Can any one please help me. Everything here works perfect except the other subroutine “&sftp()” , it works fine too when used before “&excel()” subroutine. But I want to transfer the file after it is...
4
1666
by: ashashi87 | last post by:
I'm extremely new to perl. I decided to pick it up recently and was writing some elementary code just to get the hang of things. In doing so I've come across a stumbling block for which I couldn't...
5
3607
by: ahgan | last post by:
Hi, For some reasons, I have to keep my sub-programs in 2 different .pl files. Both sub-programs are having the same subroutine name. In my main program, I need to determine which sub-program to...
0
7203
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5581
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1515
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
389
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.