combo box selected value Access XP

G

Guest

I have an unbound form with a company combo box, the fields are ID, Name,
address in the drop down (ID is hidden, address is a concatenation of all the
address columns), name is the bound column. The purpose of the form is to
order name badges for an event, some companies have multiple locations which
is the need for the address.

When an item is not in the list, they are prompted to add a new company, the
company form pops up, they fill it in, and close it. Now they are back on
the badges screen, and the combo box is requeried after adding the company
and the box still shows the company name. The person entering the badges
will most likely want to enter more for that new company, and I cannot get
the dropdown to select the new company no matter what I do.

I am a .Net developer working on a legacy project with little access
experience and do not understand why there is no selectedIndex property or
why listIndex appears to be readonly. I have tried :
1
' Dim companynameholder
' companynameholder = Me.cboCompanyName
' Me.cboCompanyName = Null
' Me.cboCompanyName.Requery
' Me.cboCompanyName = companynameholder
2
' Dim lngRow As Long
' With cboCompanyName
' For lngRow = 0 To .ListCount - 1
' If .Column(0, lngRow) = newCompany Then
' 'cboCompanyName.Value =
cboCompanyName.ItemData(lngRow)
' cboCompanyName.ListIndex = lngRow
' Exit For
' End If
' Next lngRow
' End With
3
' If lngCompanyID > 0 And IsNull(lngCompanyID) = False Then
' Me.RecordsetClone.FindFirst "[lngCompanyID] = " & lngCompanyID
' Me.Bookmark = Me.RecordsetClone.Bookmark
' End If
and a bunch of other things, any help is appreciated.
 
M

MacDermott

You lost me where you said "the box still shows the company name", then "I
cannot get the dropdown to select the new company". Unless "the box" and
"the dropdown" are not both ways of referring to the same combobox - why do
you need to select it again, if it's already displayed?
 
G

Guest

Sorry, I should have worded that better. The text for the company name is
still in the combo box on requery, but the listindex is zero, so I am losing
the company ID to assign to the new badge.

MacDermott said:
You lost me where you said "the box still shows the company name", then "I
cannot get the dropdown to select the new company". Unless "the box" and
"the dropdown" are not both ways of referring to the same combobox - why do
you need to select it again, if it's already displayed?

Whitey said:
I have an unbound form with a company combo box, the fields are ID, Name,
address in the drop down (ID is hidden, address is a concatenation of all the
address columns), name is the bound column. The purpose of the form is to
order name badges for an event, some companies have multiple locations which
is the need for the address.

When an item is not in the list, they are prompted to add a new company, the
company form pops up, they fill it in, and close it. Now they are back on
the badges screen, and the combo box is requeried after adding the company
and the box still shows the company name. The person entering the badges
will most likely want to enter more for that new company, and I cannot get
the dropdown to select the new company no matter what I do.

I am a .Net developer working on a legacy project with little access
experience and do not understand why there is no selectedIndex property or
why listIndex appears to be readonly. I have tried :
1
' Dim companynameholder
' companynameholder = Me.cboCompanyName
' Me.cboCompanyName = Null
' Me.cboCompanyName.Requery
' Me.cboCompanyName = companynameholder
2
' Dim lngRow As Long
' With cboCompanyName
' For lngRow = 0 To .ListCount - 1
' If .Column(0, lngRow) = newCompany Then
' 'cboCompanyName.Value =
cboCompanyName.ItemData(lngRow)
' cboCompanyName.ListIndex = lngRow
' Exit For
' End If
' Next lngRow
' End With
3
' If lngCompanyID > 0 And IsNull(lngCompanyID) = False Then
' Me.RecordsetClone.FindFirst "[lngCompanyID] = " & lngCompanyID
' Me.Bookmark = Me.RecordsetClone.Bookmark
' End If
and a bunch of other things, any help is appreciated.
 
M

MacDermott

ListIndex indicates the item number in the list;
MyCombo.column(0)
should return the value in the first column.

Whitey said:
Sorry, I should have worded that better. The text for the company name is
still in the combo box on requery, but the listindex is zero, so I am losing
the company ID to assign to the new badge.

MacDermott said:
You lost me where you said "the box still shows the company name", then "I
cannot get the dropdown to select the new company". Unless "the box" and
"the dropdown" are not both ways of referring to the same combobox - why do
you need to select it again, if it's already displayed?

Whitey said:
I have an unbound form with a company combo box, the fields are ID, Name,
address in the drop down (ID is hidden, address is a concatenation of
all
the
address columns), name is the bound column. The purpose of the form is to
order name badges for an event, some companies have multiple locations which
is the need for the address.

When an item is not in the list, they are prompted to add a new
company,
the
company form pops up, they fill it in, and close it. Now they are back on
the badges screen, and the combo box is requeried after adding the company
and the box still shows the company name. The person entering the badges
will most likely want to enter more for that new company, and I cannot get
the dropdown to select the new company no matter what I do.

I am a .Net developer working on a legacy project with little access
experience and do not understand why there is no selectedIndex property or
why listIndex appears to be readonly. I have tried :
1
' Dim companynameholder
' companynameholder = Me.cboCompanyName
' Me.cboCompanyName = Null
' Me.cboCompanyName.Requery
' Me.cboCompanyName = companynameholder
2
' Dim lngRow As Long
' With cboCompanyName
' For lngRow = 0 To .ListCount - 1
' If .Column(0, lngRow) = newCompany Then
' 'cboCompanyName.Value =
cboCompanyName.ItemData(lngRow)
' cboCompanyName.ListIndex = lngRow
' Exit For
' End If
' Next lngRow
' End With
3
' If lngCompanyID > 0 And IsNull(lngCompanyID) = False Then
' Me.RecordsetClone.FindFirst "[lngCompanyID] = " & lngCompanyID
' Me.Bookmark = Me.RecordsetClone.Bookmark
' End If
and a bunch of other things, any help is appreciated.
 

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