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

Populating a textbox

Hi Guys,this is my first time on bytes.I have a fair understanding of Access and can manage to get my way around it, I use macros and occasionally a bit of coding,which is all self tought; however there are times (like now) where I feel that I could do with proffessional advice.I have table tblMembers that,in which member details are captutred,eg Name ,Address,Option.each member has a UniqueID in tblMembers.The members are captured through a form that has a ComboBox with the options. As a memeber can have more than one option;is there a way I can use to populate the options textbox tblMembers with all the selected options at once.For example member 1,may have chosen Options 1,2 4,6 and 7.
any help will be appreciated.Thanks.vusunina
Nov 5 '08 #1
2 1244
missinglinq
3,532 Expert 2GB
One of the cardinal rules of relational database is that you never store more than one piece of data in any field. The proper way to do this would be to have a separate Options table and use it as the basis for a subform. When moving to a member's record on the main form, the subform would display a record for each Option that was selected by the member.

Having said that, here is the way to do what you've requested. Replace

YourOptionsComboBox

with the actual name of your combobox, and

txtOptions

with the actual name of the textbox on your form that holds the options data.

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourOptionsComboBox_AfterUpdate()
  2. If IsNull(Me.txtOptions) Then
  3.   Me.txtOptions = Me.YourOptionsComboBox
  4. Else
  5.   Me.txtOptions = Me.txtOptions & ", " & Me.YourOptionsComboBox
  6. End If
  7. End Sub
Welcome to Bytes!

Linq ;0)>
Nov 5 '08 #2
ADezii
8,834 Expert 8TB
Assuming you have a 'List' Box named lstOptions with its MultiSelect Property set to Extended, and a Text Box on your Form named txtMemberOptions, the following code will write all the Multiple Items selected in lstOptions to txtMemberOptions in a Comma Delimited Format.
Expand|Select|Wrap|Line Numbers
  1. Dim ctl As Control
  2. Dim varItm As Variant
  3. Dim strOptions As String
  4.  
  5. Set ctl = Me![lstOptions]
  6.  
  7. If ctl.ItemsSelected.Count > 0 Then
  8.   For Each varItm In ctl.ItemsSelected
  9.     strOptions = strOptions & "," & ctl.ItemData(varItm)
  10.   Next varItm
  11.   Me![txtMemberOptions] = Mid$(strOptions, 2)
  12. End If
OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. 'Assuming the User selects Option 1, Option 3, Option 6, Option 8, and Option 9
  2. Option 1,Option 3,Option 6,Option 8,Option 9
Nov 5 '08 #3

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

Similar topics

7
by: Drew | last post by:
I have a db table like the following, UID, int auto-increment RegNo Person Relation YearsKnown Now here is some sample data from this table,
0
by: ar | last post by:
If I had a form with one textbox on it and I wanted to populate that textbox on page load, how could I do that from a global procedure? I tried creating a separate class file with the following...
3
by: sck10 | last post by:
Hello, I am creating a form for users to enter information about a lab and the members of the lab. I have one form (FormView) that they use to enter information about that lab. The keyvalue is...
6
by: TB | last post by:
Hi All: I have this page where a rows / cells are programmatically added to to table by pushing a button. The rows contain a textbox and a associated button. What I want to is to be able to...
0
by: Erland | last post by:
Hello all, I have just installed visual studio .net 2005 and started developing programs in asp.net 2.0. I have a scenerio where I have to populate treeview child nodes based on the entries...
5
by: CCLeasing | last post by:
Hello, I have searched google but can not find a straight forward answer to my problem. Hopefuly someone will be kind enough to offer their expertise. Please forgive if this seems a bit convoluted...
0
by: CCLeasing | last post by:
Hello, I have searched google but can not find a straight forward answer to my problem. Hopefuly someone will be kind enough to offer their expertise. Please forgive if this seems a bit convoluted...
0
by: jvb | last post by:
Hey all, quick question I have a form with 6 tabs on it. On each tab there is a textbox which is bound to a specific column in a dataset. When I load the form, I bind all the controls, however,...
0
by: Bomac8 | last post by:
I have a text file with "|" as a delimeter with three (3) fields XXX-12345|\\YYYYYYY|\\ZZZZZZZZ I need to read these files into an output folder. The problem that I'm having is that I need to...
2
by: JonWB | last post by:
Hi, I am very new to .Net and have recently taken over someone else’s project. I am developing an asp webpage using C#. I have an asp:table that is populated using data from a database....
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: 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
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...
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.