Solved Select column value in a listbox

moke123 -Very nice idea, but should a certain filtered list exceed the number of buttons or form fields then what?
 
Last edited:
Coincidentally, I was asking in another forum, how one would handle an option group, where the values came from a table, like one would do for a combo/listbox.?
I have only ever used them with hardcoded values like Male/Female, but with that subject these days, there now appear to be many more options
?
 
SOLVED - Works Perfectly how I initially wanted it to. A couple of things to take note of.
1. It won't work if you set the listbox.columnwidths with code. you must do it thru the access application interface.
2. Following MajP's examples for FindAsYouTypeListbox, in the actual form code I had to public declare CLB as ColumnListBox at the top of the forms code

The pertinent form code to initialize the class module:
Code:
Private Sub Form_Load()
    Set CLB = New ColumnListBox
    CLB.Init Me.lstDx
.......

And my Click Code:
Code:
Private Sub lstDx_Click()
    'MsgBox CLB.ClickedColumn
    'MsgBox CLB.ClickedColumnValue
    Forms!BillingTxLU!Dx = CLB.ClickedColumnValue
    DoCmd.Close acForm, Me.Name
End Sub

Thank you everyone, especially MajP for the ideas and help.
 
I noticed in post# 19 where you posted your code, that you only had Option Compare Database. You should always also declare Option Explicit underneath that. You'll save yourself a lot of frustration.

1. It won't work if you set the listbox.columnwidths with code. you must do it thru the access application interface.
I haven't tested it but you may be able to, provided you do it prior to initializing the class. Try it.
 
Moke123. Thank you. I'll give it a try. I'm still trying to understand Class Modules and how they work. You make a lot of sense.
 
I'm still trying to understand Class Modules and how they work
This thread provides some step by step on how to build your own classes to do similar things.
 
@craigachan
FYI. When using an object you can do Declare/Initialize and Instantiation in one or two steps. I did it in one step you did it in two. This may have taken you time to figure out. This is done using the NEW keyword.

Two steps
Code:
Private CL as ColumnClickBox  ' Declare variable only

Private Sub Form_Load()
    Set CLB = New ColumnListBox 'Instantiation
     ...
end sub

One Step
Code:
Private CL as NEW ColumnClickBox  ' Declare and Instantiations

Private Sub Form_Load()
     ...
    'NO CODE NEEDED HERE to Set = New Columnlistbox
end sub
 

Users who are viewing this thread

Back
Top Bottom