473,410 Members | 1,930 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,410 software developers and data experts.

Changing Subforms Within a Mainform

I have a mainform which I want to set up as a user interface. There are no options on this form other than buttons created to open other forms. I've created the forms and they all work if I simply want to open them over the top of the main form, but what I would like to be able to click on the 'menu' item buttons to change the central subform in the body of the screen.

Any body any ideas how this can be done? I tried several codes:

Attempt 1
Expand|Select|Wrap|Line Numbers
  1. me.subfrmcontrol.sourceobject = "formname"
Attempt 2
Expand|Select|Wrap|Line Numbers
  1. With Me.subformcontrol
  2.     .LinkChildFields = ""
  3.     .LinkMasterFields = ""
  4.     .Form.Requery
  5. EndWith
But these just gave me errors, so either I've missed something like setting variables, or there's another way of doing this.

Any help would be appreciated.
Thanks
Pezzini
Feb 6 '12 #1
6 1466
NeoPa
32,556 Expert Mod 16PB
Are you saying you'd like to have a main menu-type form, which is always available, and to show various optional forms in a subform of that same main form? So the whole system will run with the main form open and active all the time, but other forms (individually and singly) are also available via the subform on the main form?
Feb 6 '12 #2
ADezii
8,834 Expert 8TB
Your Syntax is correct, as long as subFrmControl refers to the Sub-Form 'Control' itself, and not a Form Name. The following Code will load any one of three Forms into the Sub-Form Control named subFrmControl:
Expand|Select|Wrap|Line Numbers
  1. Dim strSourceSubForm As String
  2.  
  3. 'strSourceSubForm = "subFrm2"
  4. 'strSourceSubForm = "subfEmployees"
  5. strSourceSubForm = "frmInputView"
  6.  
  7. With Me![subFrmControl]
  8.   .SourceObject = strSourceSubForm
  9.   .LinkMasterFields = ""
  10.   .LinkChildFields = ""
  11.     .Requery     'Form qualifier not needed
  12. End With
Feb 6 '12 #3
@NeoPa - yes, that is exactly what I'm trying to do.

@ADezii - will give that a go when I get to work in the morning.

Thanks both
Feb 6 '12 #4
NeoPa
32,556 Expert Mod 16PB
I assume you are the erstwhile Pezzini in a new guise Gail, who has simply lost the previous sign-in details. That way I can allow you to take over the thread (which would otherwise be a hijack). If so, then please don't continue to use the Pezzini account as we don't allow members to use multiple accounts.

ADezii is correct when they indicate that the SubForm Control itself has a .Requery method that can be called. The bang (!) instead of the dot (.) is not particularly important though, and your syntax was already perfectly valid assuming the control name doesn't clash with any other reserved words or contain any space character within it. Brackets handle all names as expected though, so are always good to know about. Otherwise the only code required is the .Requery call.
Expand|Select|Wrap|Line Numbers
  1. With Me.[subfrmcontrol]
  2.     .SourceObject = "FormName"
  3.     Call .Requery
  4. End With
Nothing in ADezii's code will cause a problem of course, but I want you to understand how close you were to getting it right in the first place, and also which parts of the suggested code are the relevant ones. Only the need to include both lines in the one workable solution was missing.
Feb 7 '12 #5
This worked for me. Thanks both for your help.

@NeoPa - I'll try and figure out what the first account was and see if I can log in that way in future.

Thanks again
Feb 7 '12 #6
NeoPa
32,556 Expert Mod 16PB
Good for you Gail. Whichever account you choose is fine - but we prefer only one is used consistently. My response to your PM explains it more fully :-)
Feb 7 '12 #7

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

Similar topics

4
by: Bruce | last post by:
I need to create a stored procedure in the master database that can access info to dynamically create a view in another database. It doesn't seem like it should be very hard, but I can't get it to...
10
by: Free-Ed, Ltd. | last post by:
I am going nuts trying to find a paragraph in a book that described how to change the text content (HTML) in a DIV. Actually I have an array of HTML strings that I want to drop into the DIV,...
6
by: Saso Zagoranski | last post by:
Hi! I have a question regarding Windows Forms... Let's say I have two forms... MainForm and FormTwo... is it possible, when I open FormTwo from MainForm, to display FormTwo inside MainForm...
1
by: Paul | last post by:
There are a number of places in my app where I want the user to work with an item (a real physical item referred to by its stock number) If such an item hasn't been selected, I redirect the user...
5
by: Gary | last post by:
hi... how do I successfully resize a richtextbox within the main form, my code as follows... Private Sub frmMainForm_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles...
9
by: Jacek Jurkowski | last post by:
.... make COM exposed object to have both constructors COM visible not only the first one?
2
jinalpatel
by: jinalpatel | last post by:
I have a mainform which contains "Holder Information (name,address,dob etc) and within this mainform a subform called "LicenseInformation" (licensetype,purchasedate,amount etc) When user search...
7
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have a WinForm application that, depending on user actions, may spin for a while doing extensive calculations, showing a progress bar in the meantime. I would like to be able to launch a second...
3
by: smokinlabbit | last post by:
I'm trying to come up with a solution (but with no real direction to start with) where I'm trying to edit data in a td element of a table on the spot. What I want to do is when a td element...
5
by: opmandrake | last post by:
Evening guys. Here something that's been driving me nuts for the past couple of hours. I have a mainform and in it, two subforms. Normally I'd like the fields to be read-only, but if a user has...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.