Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Add item to List Box

Posted on 2004-03-22
8
Medium Priority
?
330 Views
Last Modified: 2008-03-04
I have a List Box with 4 columns,

And I insert the data with command

lst1.AddItem rst!col1 & ";" & rst!col2 ...(where rst is recordset)

If the rst!col1 will contain ";" (this specific character,for example "text1;text2" ) it will not work correctly.

How can I fix this problem

Thanks.
0
Comment
Question by:Irina_dusha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
8 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 10647948
do you want to replace that semicolon with another character

if so, you can use the Replace command

newText = Replace(OldText,"ReplaceFrom","ReplaceTo"

0
 
LVL 65

Accepted Solution

by:
rockiroads earned 400 total points
ID: 10647968
or you could do this, which is probably better

lst1.AddItem chr$(34) & rst!col1 & chr$(34) & ";" & chr$(34) & rst!col2 & chr$(34) & ";" ....

stick chr$(34) - equivalent of double quotes, around the field
0
 

Author Comment

by:Irina_dusha
ID: 10647977
No ,I want that ";" character will stay
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 4

Expert Comment

by:matt150279
ID: 10648009
The AddItem method doesnt work full stop in MS-Access, to my understanding.

To fill a listbox in this way you would need to set the rowsourcetype property to 'Value List' and then use code like this:-

lst1.rowsource = rst!col1 & ";" etc etc..

That should work.  The AddItem method is Visual Basic only.
0
 

Author Comment

by:Irina_dusha
ID: 10648017
to rockiroads,I didn't understand your solution ??
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 10648036
lst1.AddItem chr$(34) & rst!col1 & chr$(34) & ";" & chr$(34) & rst!col2 & chr$(34) & ";" ....

chr$(34) is the same as a double quote

what we are doing is wrapping our field with double quotes. This should then force it to take the full value and not interpret the field

I did a little test, created a value list listbox, defined some constants

Private Const X1 = "rst1"
Private Const X2 = "rs;t2"
Private Const X3 = "rst3"
Private Const X4 = "rst4"


    List1.RowSource = X1 & ";" & X2 & ";" & X3 & ";" & X4

produced 2 rows instead of one - it used the semi-colon as defined in X"


    List1.RowSource = Chr$(34) & X1 & Chr$(34) & ";" & Chr$(34) & X2 & Chr$(34) & ";" & Chr$(34) & X3 & Chr$(34) & ";" & Chr$(34) & X4 & Chr$(34)

produced just 1 row - and the 2nd column contained rs;t2
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question