load listbox function buc Access 2000

B

Brad Hood

Hi,
In our company we use Access 2000 as a "thin client"
getting all
of our information from a SQL Server database. We use a
custom
function to populate list and combo boxes which, for some
records, is
returning some wierd results. If their is a ampersand and
a space in a
name returned into the array that populates the list box,
the list box
appears to be doubling the text, i.e, "T&est Company" will
show up as
"T&est CompanTyest Company" in the list box. I was
wondering if anyone
had encountered this problem in the past since I can't
seem to find
any similar posts.

Access 2000 version: 9.0.3821 SR-1

Thanks for your time,

Brad Hood

The simplified code is below:

Create a Form and add a list box called: lstCompany
Paste in the Form Load sub: lstCompany.RowSourceType
= "LoadListBoxes"

create a new module and paste in the following code:

Public Function LoadListBoxes(ctl As Control, id As
Variant, _
row As Long, col As Long, code As Integer) As
Variant
Static vReturn As Variant
Static iCount As Integer
Static iCompanyCount As Integer
Static CompanyArray() As String
Dim i As Integer
Select Case code
Case acLBInitialize
Select Case ctl.Name
Case "lstCompany"
ReDim CompanyArray(0)
CompanyArray(i) = "T&est Company"
i = i + 1
iCompanyCount = i
vReturn = i
End Select
Case acLBOpen
vReturn = Timer
Case acLBGetRowCount
Select Case ctl.Name
Case "lstCompany"
vReturn = iCompanyCount
End Select
Case acLBGetColumnCount
vReturn = 1
Case acLBGetColumnWidth
vReturn = True
Case acLBGetValue
Select Case ctl.Name
Case "lstCompany"
vReturn = CompanyArray(row)
End Select
Case acLBEnd
Select Case ctl.Name
Case "lstExistingCompanies"
Erase CompanyArray
iCompanyCount = 0
End Select
End Select
LoadListBoxes = vReturn
End Function
 

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