473,385 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to Set Focuse to a subform control from other subform controls??

10
I have created a navigation form which contains a few nested sub forms. They are like this.

frmNavigation is the main form which has navigation buttons and a sub form named NavigationSubForm.

NavigationSubForm: Its source object is a form named sfrmNavigation.

sfrmNavigation has a sub form named subAddNewStudent.
subAddNewStudent: Its source object is a form named sfrmAddNewStudent.
I want to hide the subAddNewStudent subform with an on click event of a button on sfrmAddNewStudent. To do that I want to set focus of the button to another button on NavigationSubForm.
I am new to Visual Basic. My procedure to solve the problem may be wrong. Hope you got my problem. You will get my intention from the code below:

Private Sub btnClose2_Click()
'btnClose2 is a button on sfrmAddNewStudent
Forms! NavigationSubform.btnEdit.SetFocus
'btnEdit is a button on NavigationSubForm
Forms! NavigationSubform.subAddNewStudent.Visible = False
End Sub

It would be a great help if anyone comes forward. Thanks in advance.
Dec 18 '17 #1
3 2890
twinnyfo
3,653 Expert Mod 2GB
rawled,

You may have to state the Form explicitly, including the parent forms. For example, try using the following syntax:

Expand|Select|Wrap|Line Numbers
  1. Forms!frmNavigation.sfrmNavigation.btnEdit.SetFocus
You must use the actual object names on each form.

Hope this hepps!
Jan 3 '18 #2
rawled
10
Best way for this is to seek help from the expression builder. At first I did not know about that. I hope it will help other newbies in future.

Thanks for your reply twinnyfo.
Jan 4 '18 #3
twinnyfo
3,653 Expert Mod 2GB
Yes, the Expression Builder can be very helpful when you are unsure of the syntax. Sometimes it can get confused with deeply embedded forms (triple or quadruple nested). But for your application, this will work perfectly.

Glad I could be of some hepp!
Jan 4 '18 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Tony Williams | last post by:
I have a form on which there is a tabcontrol and on this onr of the tabpages is a tick box which opens Outlook with data from the main form and prompts the user to amend the message before being...
12
by: MLH | last post by:
I have created two forms: frmBrowseNegsMainform and frmBrowseNegsSubform. I put a subform control on the first of these. The SourceObject property for the subform control is, of course,...
7
by: kevin.jonas | last post by:
Let say I have a form called "frmMachineSpecs" witht wo subforms, "frmSpecs" and "frmMachines". Both subforms are in datasheet view. The first control in "frmSpecs" is "txtOEM_No". I want to...
3
by: Melissa | last post by:
I have forty-two small subforms on a form. I need help with the code that will return the name of the subform control when I click on any subform control. I know how to select all the subform...
10
by: Sally | last post by:
When I click on a control in a subform, what is the syntax to return the name of the subform control on the main form that contains the subform? MsgBox "MySubform is in " & < ???? > Thanks, ...
1
by: ericm1155 | last post by:
I tried using the 'Leave event' on my ListView to deselect the selected record, but the control only triggers the 'Leave event' when the user clicks on another interactive control. What I want is...
4
by: MLH | last post by:
I have a subform control on a mainform. Each time I do anything experimentally with it - like even change its Width property, A97 takes the liberty of setting values in the link child field and...
6
by: MLH | last post by:
When the vehicle entry form (frmVehicleEntryForm) first opens, the additional owner SubForm control (frmAddnlOwnrListSubForm) is enabled. You can click on it and it will accept the focus. But after...
2
by: Patrick A | last post by:
All, I have a form (FRM_ShowAll) on which I have placed a number of instances of the same sub-form (FRM_Assign) as different child forms (SFRM_Agent, SFRM_Executor, etc.). The sub-form is a...
0
by: skips84s | last post by:
I have a parent form with four tabbed subforms. On subform x, selecting a value from a combo box should update a few controls on this subform, as well as a control on subform y, all done using...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...

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.