Hello friends need your help once again.
i am trying to make a combobox of education subjects i will put all subjects to one combobox and i made 4 text boxes subject1 subject2 subject3 and subject4.
now i want to select one subject for example english
then it must enter to Subject1 another selection Maths to subject2 same others. in simple words one combobox multiple selections to one by one textbox.
how it will possible ?
I created a simple Demo for you that will hopefully explain everything in detail.
21 2150
This sample code looks for a control in UserForm1 that has "subject" in its name. If that value is blank, enter the value you selected in combobox1. - Private Sub ComboBox1_Change()
-
For Each cntrl In UserForm1.Controls
-
If cntrl.Value = "" And InStr(cntrl.Name, "subject") > 0 Then
-
cntrl.Value = ComboBox1.Text
-
Exit For
-
End If
-
Next
-
End Sub
-
-
Private Sub UserForm_Initialize()
-
ComboBox1.AddItem "mathmatics"
-
ComboBox1.AddItem "social studies"
-
ComboBox1.AddItem "history"
-
ComboBox1.AddItem "geography"
-
ComboBox1.AddItem "civics"
-
ComboBox1.AddItem "ethics"
-
ComboBox1.AddItem "chemistry"
-
ComboBox1.AddItem "physics"
-
ComboBox1.AddItem "earth science"
-
ComboBox1.AddItem "arts"
-
ComboBox1.AddItem "music"
-
End Sub
this code must be great but i am searching for something different.
see the image
there is a combobox and 3 text boxes
i want select any subject from combobox and it the text will enter into first text box and same any subject selection will enter to another box.
If you want to enter the same data in all textboxes, try removing the "exit for" statement from the sample code.
no brother if a student have 3 subjects for example maths english and physics i want put these three subjects from combobox to separate textboxes. not necessary that i will put maths english physics i can put enlish physics maths or physics maths english. but i want click subject name from combobox and put data one by one into boxes
I'm sorry, my English comprehension doesn't quite tell you what you want to do.
Maybe you need another combobox to select a language?
let me simple because i am also weak in english.
combo box ..... English
Physics
Biology
Maths
Chemistry
SubjectText1........ SubjectText2........ SubjectText3.........
i want to click and put my choice subject from combobox to SubjectText1
then i want click combobox select my choice another subject to put in subjectText2
same combobox select my choice subject to subjectText3
The sample code shown at the beginning is sufficient for that requirement.
An easier way is to make everything comboboxes instead of using text boxes.
- Instead of a Combo Box, create a List Box on your Form (lstSubjects).
- Set the MultiSelect Property of this List Box to Extended.
- Create four Text Boxes on your Form named sequentially from Text1, Text2, Text3, and Text4.
- Copy-N-Paste then following Code into the Click Event of a Command Button. It will check to see that only a Maximum of four Items in lstSubjects has been selected, then write those selections to Text1, Text2, Text3, and Text4
- Dim varItm As Variant
-
Dim intCtr As Integer
-
Dim intCtr2 As Integer
-
-
'Clear the Text Boxes
-
For intCtr2 = 1 To 4
-
Me.Controls("Text" & CStr(intCtr2)) = Null
-
Next
-
-
If Me![lstSubjects].ItemsSelected.Count = 0 Then
-
Exit Sub
-
ElseIf Me![lstSubjects].ItemsSelected.Count > 4 Then
-
MsgBox "You can only a Maximum of 4 Subjects", vbExclamation, "Invalid Entry"
-
Else '3 or more Items were selected
-
For Each varItm In Me![lstSubjects].ItemsSelected
-
intCtr = intCtr + 1
-
Me.Controls("Text" & CStr(intCtr)) = Me![lstSubjects].ItemData(varItm)
-
Next
-
End If
If you organize the requirements with my understanding
1. Empty the four text boxes.
2. When you select one item from combobox1, it will always be entered in SubjectText1.
3. Make the 1st selected item not selectable from combobox1.
4. When you select the 2nd item from combobox1, it will always be entered in SubjectText2.
5. Make the 2nd and 3rd selected items not selectable from combobox1.
6. When you select the 3rd item from combobox1, it will always be entered in SubjectText3.
7. Make the 1st, 2nd and 3rd selected items not selectable from combobox1.
8. When you select the 4th item from combobox1, it will be filled in SubjectText4.
Is it the flow of this process? If so, please point out what is different.
Hi ADezii.
In my environment, the code you showed didn't work, so I fixed it a bit to make it work.
Your idea, Listbox, will prevent it from selecting the same item. - 'Dim varItm As Variant
-
Dim intCtr As Integer
-
Dim intCtr2 As Integer
-
Dim mSelectItem As Integer
-
-
'Clear the Text Boxes
-
For intCtr2 = 1 To 4
-
Me.Controls("SubjectText" & CStr(intCtr2)) = Null
-
Next
-
-
'Set Selected items count
-
mSelectItem = 0
-
For intCtr2 = 0 To Me![lstSubjects].ListCount - 1 '
-
If lstSubjects.Selected(intCtr2) Then
-
mSelectItem = mSelectItem + 1
-
End If
-
Next
-
-
'If Me![lstSubjects].ItemsSelected.Count = 0 Then
-
If mSelectItem = 0 Then
-
Exit Sub
-
'ElseIf Me![lstSubjects].ItemsSelected.Count > 4 Then
-
ElseIf mSelectItem > 4 Then
-
MsgBox "You can only a Maximum of 4 Subjects", vbExclamation, "Invalid Entry"
-
Else '3 or more Items were selected
-
intCrt = 0
-
'For Each varItm In Me![lstSubjects].ItemsSelected
-
For intCtr2 = 0 To Me![lstSubjects].ListCount - 1
-
If Me![lstSubjects].Selected(intCtr2) Then
-
intCtr = intCtr + 1
-
'Me.Controls("Text" & CStr(intCtr)) = Me![lstSubjects].ItemData(varItm)
-
Me.Controls("SubjectText" & CStr(intCtr)) = Me![lstSubjects].List(intCtr2)
-
End If
-
Next
-
End If
In my network environment, I cannot see the posted link for my security reasons.
Use the "Insert Image" feature in the combobox of "Post your reply".
image attached kindly find the image and solve the problem
Try it with the code shown by ADezii.
The operation is the same.
The code is not working or i am not understanding to use it. could your please make a form and upload for me? please
I will explain with the code of ADezii.
The names of the TextBox are "Text1", "Text2", "Text3", and "Text4", respectively.
The name of the ListBox is "lstSubjects".
Set "MultiSelect Property" of ListBox (lstSubjects) to Extended.
If you want to select multiple items from the Listbox, hold down the Shift key while using the mouse.
i did what you said but on clicking button nothing happen not even error but no data putting in boxes.. look at image please
i want select any subject from combobox and it the text will enter into first text box and same any subject selection will enter to another box. mobdro apk tubemate
Looking at the image file of post # 14, is the name of the "Add" button Command23?
I think the position to write the code is correct.
If that doesn't work, try setting a breakpoint on any line (for example, line 6) and using the F8 key to run it line by line.
I'll Upload a Demo sometime today which will make things much clearer for you.
I created a simple Demo for you that will hopefully explain everything in detail.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: mkjets |
last post by:
I have worked for hours on trying to find a solution and have not
figured it out. I am working in Access 2003. I need to create a query
that takes values from 1 table and displays them in...
|
by: girjer |
last post by:
I want to populate two table fields on a selection of either combo box, list box or any option button.
For e.g. When I select 'YES' as an option I want to populate two fields in the table i.e....
|
by: GODSPEEDELECTRONICS |
last post by:
I have a form, where users enter an order # (key) and who they are. All in table (see links below).
From there, I want them to be able to enter the NSN # (combobox) and have the description,...
|
by: Nathan Sokalski |
last post by:
I have a Repeater that uses a DataSource that has multiple fields. When the
values of these fields is displayed in the Repeater, there are fields that
are used in combination with other fields as...
|
by: bonneylake |
last post by:
Hey Everyone,
Well i am not sure if this is more of a coldfusion problem or a javscript problem. So if i asked my question in the wrong section let me know an all move it to the correct place.
...
|
by: Michael Adams |
last post by:
I have been working on this form for quite some time with alot of help from this forum and its users. Everyone has been very helpful and there are great solutions from everyone. I also posted a...
|
by: Horace Martin |
last post by:
How do I populate multiple fields on a form by using a combo box. My combo box has 3 col. When I make a selection from my combo box all 3 fields should be filled in on my form.
eg. Form Fields:...
|
by: LeighW |
last post by:
Hi,
I'm still having a couple problems with searches.
I have a search form, frm_Search.
The form I am trying to filter, frm_Form1
An unbound combobox on frm_Search, Cbo_Permit
6 different...
|
by: cnstarz |
last post by:
Hi! I'm basically emulating a split form by having a subform in datasheet view that displays all the records of a table. Clicking on a record in the subform populates the mainform with the record's...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
| |