UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Bound Listbox, With Only 2 Choices, Office 2003    
 
   
ipisors
post Apr 24 2011, 11:27 AM
Post #1

UtterAccess Certified!
Posts: 6,937
From: Arizona, United States



I have a table with a field called Channel.

I only want there to be 2 possible values in this field, which will come from a data entry form that various users will access. the two possible values I want to be RELS and Bank Direct.

Having been advised before on this forum that it was better to avoid using some of the trickier field datatypes in the Table design (like lookup or combo/list), and instead address them at the point of data entry,...which kind of made sense to me because having table fields whose design was something like that tended to complicate the running of queries........I have the field as simply Text type in the table.

But I want on my data entry form to have a combobox or listbox (I was thinking listbox so the users can always see the values displayed as choices, and there are only 2 anyway). I'm a little confused on how to do this.

I created an unbound listbox on my form, then changed its record source to the field Channel but then when I added code:

CODE
Private Sub listchannel_Enter()
Me.listchannel.AddItem "Bank Direct", 1
Me.listchannel.AddItem "RELS", 2

End Sub
it told me the record source type had to be changed to Value List, which makes it unbound again.

How do I get users to only choose from 2 options to put in this field, without changing table design?

PS. I mean I could use checkboxes or something, but that wouldn't be bound to anything and would require some additional coding that I'm uncertain of, to get the value in the table field at the same time the form updates everything else which is all bound.

This post has been edited by ipisors: Apr 24 2011, 11:31 AM
Go to the top of the page
 
+
Doug Steele
post Apr 24 2011, 11:52 AM
Post #2

UtterAccess VIP
Posts: 17,643
From: Don Mills, ON (Canada)



I think you may have misinterpretted the error message you got. It was telling you to change the RowSourceType property to Value List (from the default Table/Query setting). That shouldn't change the list box from bound to unbound.

That being said, I don't understand why you would bother using code to set the choices if they're always going to be the same. Set the list box once, and leave it.
Go to the top of the page
 
+
ipisors
post Apr 24 2011, 12:14 PM
Post #3

UtterAccess Certified!
Posts: 6,937
From: Arizona, United States



I guess my confusion is how do I make a listbox, bound to the table where the values are going into, but only with 2 possible choices.
Go to the top of the page
 
+
Doug Steele
post Apr 24 2011, 01:09 PM
Post #4

UtterAccess VIP
Posts: 17,643
From: Don Mills, ON (Canada)



Easiest way is to use the wizard.

Failing that, do the following:
  1. Add a list box to the form
  2. Set its ColumnCount property to 2
  3. Set its RowSourceType property to Value List
  4. Set its RowSource property to Bank Direct;1,RELS;2
  5. Set its ControlSource to the name of the column to which you which to bind it
Go to the top of the page
 
+
ipisors
post Apr 24 2011, 05:08 PM
Post #5

UtterAccess Certified!
Posts: 6,937
From: Arizona, United States



when I used the wizard, none of the options, worded as such, were obvious to me as being what I needed so I was not sure if I was doing it right. Thanks for the bullet list, that gets my understanding further than the wizard. I just needed to understand clearly that ControlSource was were the data was going (bound to), and everything relating to Row- had to do with the options that would appear in the box.

As always thanks Doug!
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 23rd May 2013 - 10:36 PM