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

Combo box auto-prompt # text boxes

Hi. I am trying to do something that I'm not actually sure is possible. I am attempting to take a combo box [c_box1] and somehow have it produce textboxes. Further explanation, [c_box1] contains numbers 1-5. When a user clicks on a number within that combobox, I want the result to be that the coordinating number of textboxes will br produced under another field. I have not yet produced the combobox, so perhaps that's why this is so confusing. Allow me to go more into detail.

Positions will be the field that the combobox [c_box1] is contained within. If a user clicks the number "4" in that field, I want it to produce four textboxes under the "Line #" field.

Is this possible???
Oct 9 '07 #1
9 2971
BradHodge
166 Expert 100+
Hi. I am trying to do something that I'm not actually sure is possible. I am attempting to take a combo box [c_box1] and somehow have it produce textboxes. Further explanation, [c_box1] contains numbers 1-5. When a user clicks on a number within that combobox, I want the result to be that the coordinating number of textboxes will br produced under another field. I have not yet produced the combobox, so perhaps that's why this is so confusing. Allow me to go more into detail.

Positions will be the field that the combobox [c_box1] is contained within. If a user clicks the number "4" in that field, I want it to produce four textboxes under the "Line #" field.

Is this possible???
It would seem like it would be possible to do this using the CreateControl command in VBA along with using your combo box output to dictate the number of repeats. However, the CreateControl command requires that the form is in design view, so I'm not sure you could do this in RunTime. You can also use the CreateControl command to create Text Boxes on a new form, so maybe you could some how modify your process to do something like this.

Just a couple of thoughts.

Brad.
Oct 9 '07 #2
missinglinq
3,532 Expert 2GB
How about creating the maximum number of textboxes, set their visibilty as No by Default, and then, in the AfterUpdate event of the combobox, make the appropriate number of boxes visible?

Then, in the Form Current event, makes the text boxes visible if they contain data.

Linq ;)>
Oct 9 '07 #3
How about creating the maximum number of textboxes, set their visibilty as No by Default, and then, in the AfterUpdate event of the combobox, make the appropriate number of boxes visible?

Then, in the Form Current event, makes the text boxes visible if they contain data.

Linq ;)>
I'm new to this so please be patient. :) If this is a new database that I am making, would the "Form Current" event you spoke of be visible to those who will later be using this form on this particular database? I don't want them to be able to change anything to do with the database itself, only with the records and information contained in those records.

Sorry if that's a dumb question. :)

Thanks for the responses *that's to both of you!!!*
Oct 9 '07 #4
missinglinq
3,532 Expert 2GB
We understand that everyone has to start somewhere, but you're really talking about the very basic ABCs of Access/VBA programming here. If you're really going to do this, you'll need to get a decent primer on MS Access (by preference, one for your particular version) that includes at least the very basics of writing code, i.e. how to access the code window, etc. We're happy to answer questions here, that's what we do, but this is not a suitable forum for teaching Access to someone from the ground up.

The Form_Current() event (which you may also see referred to as the On Current event) resides in the Code Module for a form, and shouldn't be available to the end users. It will always look similar to this

Private Sub Form_Current()
'Your code goes here
End Sub

The code in this sub fires whenever a record is loaded. When the form itself loads (because the first record is loaded) and anytime you move from one record to another. Because of this, you place code here that you want executed each time a new record is accessed. One example of this would be code to make your textboxes visible, but only if they contain data.

If you have, for example, three textboxes that may or may not need to be displayed, depending on whether they contain data or not, you'd do something like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.  
  3. If  IsNull(TextBox1) Then  
  4.  TextBox1.Visible = False
  5. Else
  6.  TextBox1.Visible =  True
  7. End If
  8.  
  9. If  IsNull(TextBox2) Then  
  10.  TextBox2.Visible = False
  11. Else
  12.  TextBox2.Visible =  True
  13. End If
  14.  
  15. If  IsNull(TextBox3) Then  
  16.  TextBox3.Visible = False
  17. Else
  18.  TextBox3.Visible =  True
  19. End If
  20.  
  21. End Sub
If IsNull(TextBox1)

asks if the box named TextBox1 IsNull (is empty)

If it is null, or empty, it's not displayed

TextBox1.Visible = False

Else (if it's not null, it has data) it is displayed

TextBox1.Visible = True

BTW, the line numbersyou see in the code above are for display purposes here in the forum, and should not appear in the actual code.
Linq ;0)>
Oct 9 '07 #5
We understand that everyone has to start somewhere, but you're really talking about the very basic ABCs of Access/VBA programming here. If you're really going to do this, you'll need to get a decent primer on MS Access (by preference, one for your particular version) that includes at least the very basics of writing code, i.e. how to access the code window, etc. We're happy to answer questions here, that's what we do, but this is not a suitable forum for teaching Access to someone from the ground up.

The Form_Current() event (which you may also see referred to as the On Current event) resides in the Code Module for a form, and shouldn't be available to the end users. It will always look similar to this

Private Sub Form_Current()
'Your code goes here
End Sub

The code in this sub fires whenever a record is loaded. When the form itself loads (because the first record is loaded) and anytime you move from one record to another. Because of this, you place code here that you want executed each time a new record is accessed. One example of this would be code to make your textboxes visible, but only if they contain data.

If you have, for example, three textboxes that may or may not need to be displayed, depending on whether they contain data or not, you'd do something like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.  
  3. If  IsNull(TextBox1) Then  
  4.  TextBox1.Visible = False
  5. Else
  6.  TextBox1.Visible =  True
  7. End If
  8.  
  9. If  IsNull(TextBox2) Then  
  10.  TextBox2.Visible = False
  11. Else
  12.  TextBox2.Visible =  True
  13. End If
  14.  
  15. If  IsNull(TextBox3) Then  
  16.  TextBox3.Visible = False
  17. Else
  18.  TextBox3.Visible =  True
  19. End If
  20.  
  21. End Sub
If IsNull(TextBox1)

asks if the box named TextBox1 IsNull (is empty)

If it is null, or empty, it's not displayed

TextBox1.Visible = False

Else (if it's not null, it has data) it is displayed

TextBox1.Visible = True

BTW, the line numbersyou see in the code above are for display purposes here in the forum, and should not appear in the actual code.
Linq ;0)>
Many thanks for your reply Linq as well as my sincerest apologies that you feel I'm entirely learning Access via the advice given on this forum. I have worked in Access, and am familiar with some things, others are foreign to me. I can clearly see why you thought me a total novice based on the answer you gave me. You gave examples and code for simply displaying textboxes, which was not what I was wanting. In fact, given the examples I provided and the correspondence elsewhere in this post, you'll easily find I was asking how to provide blank textboxes in correlation with a combo box. I was aware of the codes you provided and their meanings, just not exactly how to tailor it to my needs.

I appreciate the help/guidance other users on this forum have offered, and hope the little guidance I have offered to others was beneficial. That being said, I would never feel comfortable seeking voluntarily offered advice where it is clearly not offered to "novices" such as myself. Thank you for your time. Have a great day. :)
Oct 9 '07 #6
MMcCarthy
14,534 Expert Mod 8TB
I'm new to this so please be patient. :) If this is a new database that I am making, would the "Form Current" event you spoke of be visible to those who will later be using this form on this particular database? I don't want them to be able to change anything to do with the database itself, only with the records and information contained in those records.

Sorry if that's a dumb question. :)

Thanks for the responses *that's to both of you!!!*
deanndra

missinglinq was not trying to insult you but trying to be helpful. Being familiar with Access structures and understanding VBA (which is what the Forms On Current event is about) are two different things. Putting code in the On Current event of the form or any other event is standard VBA coding. You spoke of that being "available" to the user. This led missinglinq to understand that you weren't familiar with VBA event coding.

Hiding the structure of the database which would include code from the user requires you to create an mde file. If you want help with that we are happy to provide it.

Again as I say missinglinq was not trying to insult you. Many Access users are unfamiliar with VBA. However, it is an integral part of creating a modern user friendly Access database. Getting a good Access/VBA book is a great place to start learning this stuff.

Mary
Oct 10 '07 #7
Hi. I am trying to do something that I'm not actually sure is possible. I am attempting to take a combo box [c_box1] and somehow have it produce textboxes. Further explanation, [c_box1] contains numbers 1-5. When a user clicks on a number within that combobox, I want the result to be that the coordinating number of textboxes will br produced under another field. I have not yet produced the combobox, so perhaps that's why this is so confusing. Allow me to go more into detail.

Positions will be the field that the combobox [c_box1] is contained within. If a user clicks the number "4" in that field, I want it to produce four textboxes under the "Line #" field.

Is this possible???
I'm still working on this. So far, I have a combo box named CBPos bound to tbl_PositionsAir, and 10 textboxes bound to separate fields within tbl_ParaAir. I have placed the following code in VBA for CBPos:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CBPos_AfterUpdate()
  2.   If IsNull(Me.CBPos) Then
  3.     Me!Para1.Visible = False
  4.     Me!Para2.Visible = False
  5.     Me!Para3.Visible = False
  6.     Me!Para4.Visible = False
  7.     Me!Para5.Visible = False
  8.     Me!Para6.Visible = False
  9.     Me!Para7.Visible = False
  10.     Me!Para8.Visible = False
  11.     Me!Para9.Visible = False
  12.     Me!Para10.Visible = False
  13.   Else
  14.     Me.CBPos = "1"
  15.     Me!Para1.Visible = True
  16.     Me!Para2.Visible = False
  17.     Me!Para3.Visible = False
  18.     Me!Para4.Visible = False
  19.     Me!Para5.Visible = False
  20.     Me!Para6.Visible = False
  21.     Me!Para7.Visible = False
  22.     Me!Para8.Visible = False
  23.     Me!Para9.Visible = False
  24.     Me!Para10.Visible = False
  25.   End If
  26. End Sub
Now my understanding was that this would be quite tedious having to enter all that for each Pos possibility (values 1-10), but I decided in the end it would probably be easier. However, now the problem I am having is not with hiding the textboxes...all textboxes (Para1-10) are set to invisible. And the numbers 1-10 do appear in CBPos as they should. However, if I go to click on "1" in CBPos, first of all it won't even let me click on it. The cursor simply highlights it and does nothing, so obviously this will not allow any textboxes to appear. And I can't for the life of me understand this. I have changed the code in the AfterUpdate procedure a dozen times...to no avail. I did see something online abotu a Tag property, as well as something for a Function, and wondered if perhaps I wasn't setting this up all wrong. Clueless. Any ideas on what I've coded wrong?
Oct 16 '07 #8
Ooops, I forgot to put in my last reply that the following code is also located with the other code in CBPos:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.   Me!Para1.Visible = False
  3.   Me!Para2.Visible = False
  4.   Me!Para3.Visible = False
  5.   Me!Para4.Visible = False
  6.   Me!Para5.Visible = False
  7.   Me!Para6.Visible = False
  8.   Me!Para7.Visible = False
  9.   Me!Para8.Visible = False
  10.   Me!Para9.Visible = False
  11.   Me!Para10.Visible = False
  12. End Sub
Oct 16 '07 #9
NeoPa
32,556 Expert Mod 16PB
If you leave your OnOpen code as it is, you may find the following code a less tedious replacement for the AfterUpdate event.
Expand|Select|Wrap|Line Numbers
  1. Private Sub CBPos_AfterUpdate()
  2.   Dim intX As Integer
  3.  
  4.   For intX = 1 To 10
  5.     Me.Controls("Para" & intX).Visible = (CBPos >= intX)
  6.   Next intX
  7. End Sub
Oct 21 '07 #10

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

Similar topics

0
by: Bill K | last post by:
Does the vb.net combo box control have the auto complete/expand feature like the Access combo box - where you begin typing in the conbo box and the first possible choice appears? If so, how do...
3
by: sao | last post by:
I am currently using Access 2000. In my table it is the following fields that are set up: 1 - Staff Name 2 - Department This table is already populated with 100+ records (staff along with...
2
by: Dwight | last post by:
Help ! Have a combo box in accsess, with 6 fields, I want each to show up a different colour when they ar selected/viewed. I have tried the following code but seems to have no affect can anyone...
2
by: Jim Devenish | last post by:
I have a combo box with Auto Expand and Limit to List both set to 'yes'. When I type 'C' I correctly get: C J Valeting When I type 'CO' I get: Cogent Seating Ltd again correct BUT when I go...
0
by: VenuGopal | last post by:
hi, i have implemented a MultiColumn Combo by overriding thr Combo Box's DropDown Event. In the Event i have populated a DataTable to contain the Necessary MultiColumns. Now i need to implement...
0
by: Gautam Dasaka | last post by:
Hi, I am creating an Access database form to store invoice information in the same file. This is a single user file, but tested on a few workstations.. I am using a combo box (CboSupplier_List)...
1
by: pemigh | last post by:
In a prior posting (too old to reply directly), Jim Devenish described exactly what my client has seen, both in terms of AutoExpand behaving oddly and the way that caps lock relates to the...
3
by: John | last post by:
AC2007 I changed my combo's row source and then the autocomplete stopped working. The combo is two columns, bound to the first. First column is primary key (ID). Second column is a...
4
by: scolivas | last post by:
I think this is a me thing. but can't remember how to do it. I have a form that I am using and would like for a txt box to automatically populate based on what is selected in a combo box. here...
3
by: mahesh123 | last post by:
Hi Folks, I want Help regarding the Auto search in the Combo Box. When I am pressing the characters it will move to the appropraite words in the Combo Box. For Example if the Combo Box filled...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.