Adding Custom List to Combo Dropdown in Form

S

SuperOpus

I'm trying to add a custom list of 2 items in a combo dropdown in a form.
The code I'm using is 'partially' working. The problem is this: Even
though I'm scrolling through the list (a filtered list of records), it grabs
the record #1 info to build my dropdown list. They want some dropdowns in
other spots similar to this one if I can get it working. I didn't see any
options along the lines of form.currentrecord.lastname, but that's what I'm
asking for.

Can anyone help???

TIA

Steve

Function ListSalutation(fld As Control, id As Variant, _
row As Variant, col As Variant, code As Variant) _
As Variant
Dim intOffset As Integer
Select Case code
Case acLBInitialize ' Initialize.
ListSalutation = True
Case acLBOpen ' Open.
ListSalutation = Timer ' Unique ID.
Case acLBGetRowCount ' Get rows.
ListSalutation = 2
Case acLBGetColumnCount ' Get columns.
ListSalutation = 1
Case acLBGetColumnWidth ' Get column width.
ListSalutation = -1 ' Use default width.
Case acLBGetValue ' Get the data.
Select Case row
Case 0
ListSalutation = [Title] & " " & [LastName]
Case 1
ListSalutation = [FirstName]
End Select
End Select
End Function
 
A

Albert D.Kallal

I don't understand quite what you are doing here?

Is there any particular reasons you are using the call back function that
you have?

When you say add 2 items. you mean to a existing list in a comb box, or that
you just simply need 2 items in the combo box?

If it is just a few items, then set the combo box to use a value list..and
simply stuff the two values separated by a semi-colon like

me.mycombobox.RowSource = "First entry;Second Entry"

If you need to build a full list of names into the combo box, then just use
the wizard.

Perhaps explain a bit more what you are trying to do here..but, I don't
think you need the call back function to accomplish what you need...

Where is the data coming from that you plan to use in the combo box?
 
S

SuperOpus

While I'm certainly glad to use a value list (I thought I tried that to no
avail -- must've been a typo), I'm trying to 'glean' the last name, first
name, title, etc... from the Current Record being displayed on the form.
I'll try your value list and see if that clears things up. Thank you!
 
S

SuperOpus

it appears the the value list ONLY gives me a list of what I type instead of
looking up the data I need. How do I get it to look up, in the easiest
manner, the FistName, Title, and Lastname fields for the current record?
 
S

SuperOpus

Geeze... I got it. Thank you so much!!! I put the combo row source in the
enter method of the combo. Does EXACTLY what I needed.

THANK YOU!
 
A

Albert D.Kallal

SuperOpus said:
it appears the the value list ONLY gives me a list of what I type instead
of
looking up the data I need. How do I get it to look up, in the easiest
manner, the FistName, Title, and Lastname fields for the current record?


What do you mean by lookup the current record? IF you are on the current
record, you can see everything, and why would you need to lookup anything?

Perhaps you mean you want to use a combo box to display list of names, and
when you select a name from the combo box,t he record MOVES to that record
for display and editing of data?

However, if you are on the current record, why would you need to lookup the
name when you can see it, and are looking at it?

Something here is not being explained....
 
S

SuperOpus

It was my fault... I was trying to enter the information as a formula
directly in the rowsource property (ie: me.lastname;me.firstname) which was
how my dropdown list appeared! DOH! It worked perfectly after I entered
this into the methods:

Private Sub Dear_Enter()
Me.Dear.RowSource = Me.Title & " " & Me.LastName & ";" & Me.FirstName
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top