473,320 Members | 1,846 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,320 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 7300
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.