473,625 Members | 2,717 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Opening a subform based on the option selected in a main form

jinalpatel
68 New Member
I have three option buttons (1 option group): construction projects, non construction projects and aquisition projects.

I have created a form with more than 35 data entry fields for each of this options.ex.frmC onstructionProj ects,frmNoncons tructionProj, frmAquisitionPr ojects

When user selects an option fromm the options group it should open the respective subform.
Expand|Select|Wrap|Line Numbers
  1. Private Sub optProject_Click()
  2. If Me.optProject.Value = 1 Then
  3. DoCmd.OpenForm "frmNonConstructionProj
  4. Else
  5. If Me.optProject.Value = 2 Then
  6. DoCmd.OpenForm "frmConstructionProjects
  7. Else
  8. If Me.optProject.Value = 3 Then
  9. DoCmd.OpenForm "frmAquisitionProjects"
  10. End If
  11. End If
  12. End If
  13. End Sub
  14.  
It opens a new form rather than putting it like a subform under the option group object. How to make it look like a subform which only contains a data respective to the selected option?

Thanks !!
Mar 24 '09 #1
21 6559
ChipR
1,287 Recognized Expert Top Contributor
It sounds like you want to use a Tab control, and put the appropriate data on each tab page.
Mar 24 '09 #2
jinalpatel
68 New Member
Thats one way!!
here is some change in req.
I want all those option buttons on main tab. When user selects one of the option the respective subform (or form)should be opened on 11th tab.
The goal here is :Not giving user the access to all the three kinds of prjects type's data entry fields!!
thanks much!!
Mar 24 '09 #3
ChipR
1,287 Recognized Expert Top Contributor
You could have 3 subforms and show/hide them. Or, if the format of the subform is the same, you could just dynamically set the source for a single subform.
Actually, it doesn't seem like you need a subform, just a bunch of controls (data entry fields) that you can hide/unhide.
Mar 24 '09 #4
jinalpatel
68 New Member
Where to write the code for show/hide the subform and how?
Is it under the click event of the 11th tab (page)?
something like
Expand|Select|Wrap|Line Numbers
  1. If Me.optProject = 1 Then
  2. Show "frmConstructionProjects"
  3. End If
  4.  
Mar 24 '09 #5
ChipR
1,287 Recognized Expert Top Contributor
I'd probably keep it in the option group's After_Update. Then you won't change it needlessly. You can do:
Expand|Select|Wrap|Line Numbers
  1. mySubform.Visible = True
Mar 24 '09 #6
jinalpatel
68 New Member
thanks for the help!!
Mar 24 '09 #7
ChipR
1,287 Recognized Expert Top Contributor
You probably want to set one form to Visible = True, and the other two forms to Visible = False in the AfterUpdate code that you already have. Are there 3 values for your optProjects, because you need a case for each of them.

None of the subforms are going to be visible if the user isn't viewing the tab that they are on anyway, but if you really want to hide them you can watch for the tab control's Change() event, test the value of the tab control to see what # tab is now being viewed, and hide/show things accordingly.
Mar 24 '09 #8
jinalpatel
68 New Member
Thanks ChipR for your help!! I appreciate it.
Mar 24 '09 #9
jinalpatel
68 New Member
Here is the code if anybody is looking at this thread for help themselves!!
Expand|Select|Wrap|Line Numbers
  1. Private Sub optProjects_AfterUpdate()
  2. If Me.optProjects.Value = 1 Then
  3. frmConstructionProjects.Visible = True
  4. frmNonConstructionProj.Visible = False
  5. frmAquisitionProjects.Visible = False
  6. End If
  7.  
  8. If Me.optProjects.Value = 2 Then
  9. frmNonConstructionProj.Visible = True
  10. frmConstructionProjects.Visible = False
  11. frmAquisitionProjects.Visible = False
  12. End If
  13.  
  14. If Me.optProjects.Value = 3 Then
  15. frmAquisitionProjects.Visible = True
  16. frmConstructionProjects.Visible = False
  17. frmNonConstructionProj.Visible = False
  18. End If
  19.  
  20. End Sub
OR

Expand|Select|Wrap|Line Numbers
  1. Private Sub optProjects_AfterUpdate()
  2. Select Case Me.optProjects
  3.  
  4. Case 1
  5.  
  6. frmConstructionProjects.Visible = True
  7. frmNonConstructionProj.Visible = False
  8. frmAquisitionProjects.Visible = False
  9.  
  10.  
  11. Case 2
  12.  
  13. frmNonConstructionProj.Visible = True
  14. frmConstructionProjects.Visible = False
  15. frmAquisitionProjects.Visible = False
  16.  
  17. Case 3
  18.  
  19.  
  20. frmAquisitionProjects.Visible = True
  21. frmConstructionProjects.Visible = False
  22. frmNonConstructionProj.Visible = False
  23.  
  24. Case Else
  25. frmAquisitionProjects.Visible = False
  26. frmConstructionProjects.Visible = False
  27. frmNonConstructionProj.Visible = False
  28. End Select
  29.  
  30. End Sub
  31.  
I know it is easy but still!!!
Mar 24 '09 #10

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

Similar topics

0
2347
by: CSDunn | last post by:
Hello, In Access ADP's that connect to SQL Server databases, any time I have a situation where I have a combo box in a main form that looks up a record in a subform, the subform record source has to be based on either a View or a Table. I can almost always use a View, and it helps to do this since I can have better control over the size of the RecordSet of the subform. There are times when the use of a Stored Procedure would give me...
1
2341
by: Alienz | last post by:
Alien hello to whoever is reading today. Ill try to explain this as simply as possible its just a weird thing thats happening here in Access 2000 subforms.. I think something small is out of place. If you have a sec to share some human thoughts it would be much appreciated!!! I created a subform that is linked to a main form. I locked all of the combo boxes in the subform and basically my goal is to have the subform display whatever...
25
10212
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the data in each record, which includes the ID of the father and the mother (who also have records in the table). One record per form. I have a Tab Control in the form, and in one of the tabs I have a subform (sfmSiblings) in which I wish to list...
2
2233
by: Lyn | last post by:
Hi, I am working on a genealogy project in which I have two tables: Person -- one record for each person in the family. Each record has a unique Autonum field (IDPerson). Partnerships -- one record for each marriage. Each record has a unique Autonum field (ID), and also contains two fields IDPartnerMale and IDPartnerFemale. Both of the latter fields match records in the Person table via IDPerson.
1
2148
by: NBruch | last post by:
Ok let me explain what im trying to do: i need a combo box which needs to be linked to a listbox (or combo box doesnt matter which really) then the listbox should bring up the record in a subform. so you pick a name (in the combo box in the main form) then it should bring up all the dates for which the person has a record for (in the list box or combo box) and then once you pick a date it should bring up the specific record you want...
9
2737
by: PC Datasheet | last post by:
I'm stuck on something that seems should be easy and I need some help. My main form has an option group with five options. My subform chooses from different lists depending on which option is selected in the main form. I thought all I had to do for the subform was create a query and set the criteria equal to the option group value in the main form. No way, Jose! When the form/subform opens, the option group value is not available to the...
2
4287
by: David W. Fenton | last post by:
I think at various times we've all encountered this problem: A subform is on a main form. From the code of the main form we refer to some property of/control on the child form thus: Me!subForm.Form!txtTextBox and for some reason, in certain contexts, we get the error: Error 2455: You entered an expression that has an invalid reference
9
15834
by: natwong | last post by:
Hi All, I'm a newbie in terms of Access and some of its functionality . I've been stuck on this problem for a couple days, even after searching the Web, etc. Currently I have five combo boxes (actually list boxes) that are multiselects in my main form. I need to use these combo boxes to filter a subform within my main form. My combo boxes are as follows: 1. A - 4 select options 2. B - 10 select options 3. C - 4 select options
1
1671
by: Coll | last post by:
I have a form with a subform on it. On my main form, you select an employee id number and the top portion of form fills in with data, and the bottom portion of the form,which is a subform, lists existing records there are for that employee (one to many relationship). How can I set up my main form, so the user can select one of the records on the subform and retain that recordid number for use in opening a new form and displaying the that...
0
8692
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8354
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6116
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4192
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
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 we have to send another system
1
1802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1499
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.