473,396 Members | 2,030 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,396 software developers and data experts.

COMBO BOX...create with code

Has anyone created a combo box from scratch with vba in access? I would like the AFTER UPDATE event to create a combo box and populate it with items dependent on what the user selects. I know how to populate programatically, but haven't figured out how to CREATE the combo box programatically. Thank you in advance!
Feb 8 '07 #1
3 7327
nico5038
3,080 Expert 2GB
The easy way os to place the combobox and set the Visible property to False.
When the selection of the first combo has been made use:

Expand|Select|Wrap|Line Numbers
  1. if LEN(NZ(me.combo1)) > 0 then
  2.   Me.combo2.recordsource = "select X from tblY where ID=" & me.combo1
  3.   Me.combo2.visible = true
  4. else
  5.   Me.combo2.visible = false
  6. endif
  7.  
This will activate the second combo when a selection has been made.
Getting the idea ?

Nic;o)
Feb 8 '07 #2
ADezii
8,834 Expert 8TB
Has anyone created a combo box from scratch with vba in access? I would like the AFTER UPDATE event to create a combo box and populate it with items dependent on what the user selects. I know how to populate programatically, but haven't figured out how to CREATE the combo box programatically. Thank you in advance!
What you are asking is impossible and I'll explain why.To create a variety of Controls you must use, oddly enough, the CreateControl Method.This Method is used in a Custom Wizard to create Controls in a Form or Report only. This Method can 'only' be used in Form or Report Design View so what you are requesting is not feasible. If you are still interested though, here goes the syntax:

Expand|Select|Wrap|Line Numbers
  1. Dim MyControl As Control
  2. Set MyControl = CreateControl("frmTest", acComboBox, acDetail, , "", 2880, 2880, 2000, 300)
  3.  
  4. Parameter Explanations
  5. __1 frmTest - name of the Form on which you want to create the Control.
  6. __2 acComboBox - intrinsic Constant identifying Type of Control to create.
  7. __3 acDetail - intrinsic Constant identifying the Section that will contain the new Control.
  8. __4  "" - name of the Parent Control (if none, empty string).
  9. __5 2880 - left offset from the Form in Twips (1 in. = 1440 Twips). - 2 in.
  10. __6 2880 - top offset from the Form in Twips (1 in. = 1440 Twips). - 2 in.
  11. __7 2000 - width of Control in Twips (approx. 1,4 in).
  12. __8  300 - heigth of the Control in Twips (approx. .21 in).
  13.  
  14. NOTE: To actually see this in action, place your Form in Design view, 
  15. replace frmTest with your Form Name, create a Public Function 
  16. Procedure, then run it from the Debug Window. Sorry that you asked this question?
Feb 9 '07 #3
What you are asking is impossible and I'll explain why.To create a variety of Controls you must use, oddly enough, the CreateControl Method.This Method is used in a Custom Wizard to create Controls in a Form or Report only. This Method can 'only' be used in Form or Report Design View so what you are requesting is not feasible. If you are still interested though, here goes the syntax:

Expand|Select|Wrap|Line Numbers
  1. Dim MyControl As Control
  2. Set MyControl = CreateControl("frmTest", acComboBox, acDetail, , "", 2880, 2880, 2000, 300)
  3.  
  4. Parameter Explanations
  5. __1 frmTest - name of the Form on which you want to create the Control.
  6. __2 acComboBox - intrinsic Constant identifying Type of Control to create.
  7. __3 acDetail - intrinsic Constant identifying the Section that will contain the new Control.
  8. __4  "" - name of the Parent Control (if none, empty string).
  9. __5 2880 - left offset from the Form in Twips (1 in. = 1440 Twips). - 2 in.
  10. __6 2880 - top offset from the Form in Twips (1 in. = 1440 Twips). - 2 in.
  11. __7 2000 - width of Control in Twips (approx. 1,4 in).
  12. __8  300 - heigth of the Control in Twips (approx. .21 in).
  13.  
  14. NOTE: To actually see this in action, place your Form in Design view, 
  15. replace frmTest with your Form Name, create a Public Function 
  16. Procedure, then run it from the Debug Window. Sorry that you asked this question?

Thank you for all your help!
Feb 9 '07 #4

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

Similar topics

0
by: Morten Gulbrandsen | last post by:
Hello, starting from some software database spesification, defined in some Enhanced entity relationship diagram, resulting in all kinds of relationships, 1:1 1:Many Many:1
3
by: Miya | last post by:
I am building a calendar to enter and display training courses. I have a table with the fields CourseID, TrainingDate, TrainingStartTime and TrainingEndTime. Some courses are one day while others...
1
by: Russell Mangel | last post by:
Is it possible to create code comments in VC++ 2003.NET? I have created a Mixed-mode .dll which will be called from C#.NET or VB.NET. When I add a reference to this .net .dll file using C# or...
3
by: Jan Nielsen | last post by:
Hi I have a form with a combo on it The combos items is a list of groups (ie coworker, parent, friend) which it gets from a dataset when the form loads. When the user selects a group from the...
7
by: Ronald S. Cook | last post by:
Thanks for reading this... Our current Win app employs a ListView control wherein the tag for an item is, for example, "ContentManager.DataModel.PowerPointContent". The following code exists...
8
by: Jack | last post by:
Hi, I have a asp page where multiple rows for a client is generated using asp. Some of these are combo boxes and some are text and are coming from a recordset. Now, the following is the code to...
6
by: jambonjamasb | last post by:
Hi All, I am now on the next part of my quest. I have built my Form, which has used subforms to show my records and what I need to complete as the POL authority. I am now trying to jazz the...
3
kcdoell
by: kcdoell | last post by:
I have 5 cascading combo boxes on a form. Below is a sample of my vb in the first combo box: Private Sub CboDivision_AfterUpdate() 'When the Division is selected, the appropriate Segment...
14
by: Just_a_fan | last post by:
In VB6, I could easily take the value from a combo box and make a command with it, this: baudrate = cboBaud(listindex). With the new dotted stuff in VB9, I can't seem to do that. Here's an...
6
by: kkshansid | last post by:
<?php echo"<select name=$sarea >"; $option = "<option value=\"Please select a Subject Area\">Please select a Subject Area</option> \n"; for ($i = 0; $i < count($subjarea); $i++) {...
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...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.