Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List Box and SQL

Status
Not open for further replies.

tyleri

Programmer
Jan 2, 2001
173
US
I have a task that I know is doable but is confusing to me.
I have 3 fields in a table that have the values 0 or 1.

Field 1: 0 = nothing 1 = New Account
Field 2: 0 = nothing 1 = Banking Account
Field 3: 0 = nothing 1 = Broker

I want the list box to show each record with a listbox that shows ONLY what the client DOES have.

So if one client only has "Banking Account", then I want the list box to show: Banking Account

If the client has "Broker and Banking Account" I want the list box to show:

Broker
Banking Account

just like that - no NULL values!

Does anyone understand what I"m talking about and can show me the code that I must use to get this?

Thanks in advance!

 
set the listboxes row source type as value list
then in the forms on current event use code like this

Private Sub Form_Current()
Dim txtstr As String
txtstr = ""
If Me.Field1 = 1 Then txtstr = "New Account"
If Me.Field2 = 1 Then txtstr = "Banking Account ," & txtstr
If Me.Field3 = 1 Then txtstr = "Broker ," & txtstr
Me.List0.RowSource = txtstr
 
I put in this code:

Private Sub External_Clients_Current()

Dim txtstr As String
txtstr = ""
If Me.EXT_USER_Q.new_acct_ind = 1 Then txtstr = "New Account "
If Me.EXT_USER_Q.bank_ind = 1 Then txtstr = "Banking " & txtstr
If Me.EXT_USER_Q.broke_ind = 1 Then txtstr = "Broker " & txtstr

Me.Services_List.RowSource = txtstr

End Sub


it's not working..... any ideas?

 

Listbox data is derived from a Table/Query, Value List or a Field List. What you want is a Value list. The Entries in the Value List are separated with semi-colons:

Code:
If Me.EXT_USER_Q.new_acct_ind = 1 Then txtstr = "New Account
;
Code:
"
If Me.EXT_USER_Q.bank_ind = 1 Then txtstr = "Banking
;
Code:
 " & txtstr
If Me.EXT_USER_Q.broke_ind = 1 Then txtstr = "Broker " & txtstr

Me.services_list.RowSourceType = "Value List"
Me.services_list.ColumnCount = 1
Me.services_list.rowsource = txtstr

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top