473,402 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

load list box function bug

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
Nov 12 '05 #1
2 2055
Brad,

Rather than "Static vReturn As Variant"
Try "Dim vReturn As Variant"

For correctness, you may also want to look at the lines:
Case acLBEnd
Select Case ctl.Name
Case "lstExistingCompanies" <<<<<

Looks like you wanted:
Case "lstCompany"

-dp

Sp*******@msn.com (Brad Hood) wrote in message news:<56*************************@posting.google.c om>...
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

Nov 12 '05 #2
Thanks. The dim declaration did the trick. Maybe someone should let
microsoft now about this in their "Creating Combo Boxes and List Boxes
in Microsoft Access" article :)

http://www.microsoft.com/accessdev/articles/combo.htm

dp****@app-tech.com (Dave Perry) wrote in message news:<a0**************************@posting.google. com>...
Brad,

Rather than "Static vReturn As Variant"
Try "Dim vReturn As Variant"

For correctness, you may also want to look at the lines:
Case acLBEnd
Select Case ctl.Name
Case "lstExistingCompanies" <<<<<

Looks like you wanted:
Case "lstCompany"

-dp

Sp*******@msn.com (Brad Hood) wrote in message news:<56*************************@posting.google.c om>...
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

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Donald Tyler | last post by:
Then the only way you can do it that I can think of is to write a PHP script to do basically what PHPMyAdmin is trying to do but without the LOCAL in there. However to do that you would need to...
0
by: Peter | last post by:
When I issue call sqlj.install_jar('file:///f:/jars/mail.jar','MAIL'); I get the messages SQL4301N Java or .NET interpreter startup or communication failed, reason
2
by: Brad Hood | last post by:
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...
9
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter...
15
by: H00ner | last post by:
Hello All Hope you can help Been pulling my hair out about a popup problem in ASP.NET. One of the forms i wrote requires the user to select a product from a list in a popup web form. the...
3
by: gilbert3b2g | last post by:
I'm new to Python, and programming in general. What I'm trying to do here is to load a list of accounts from a file on my harddrive into a string of Buttons in Tkinter, and when I press one of the...
3
by: Ronald S. Cook | last post by:
I lost my last post, but I'm looking for a better way to manage loading user controls (that are essentially forms) in a Windows app. In my current design, I have a ListBar in which the user...
1
by: jianxin9 | last post by:
Hi, I have an ajax powered tabs box that has a javascript drop-down search menu in the first tab. When I click on another tab, and go back to the first tab I have to refresh the page to get the...
3
by: Queez | last post by:
Very quick question. I have a master page (M1) and three content pages (C1, C2, C3). In M1, there's a list of three anchors (A1, A2, A3) which point towards the three content pages. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.