PC Review


Reply
Thread Tools Rate Thread

Another listbox problem

 
 
FR
Guest
Posts: n/a
 
      2nd Oct 2008
Trying to populate a listbox using additem (Access 2007 VBA). Whenever an
item to be added contains a comma, it truncates it at that spot. Could it be
that it mistakes the comma for a semicolon and expects it to belong to a
different column?
 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      2nd Oct 2008
Try putting quotes around it.

Instead of

MyListbox.AddItem "1;A, B, C"

try


MyListbox.AddItem "1;""A, B, C"""



--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"FR" <(E-Mail Removed)> wrote in message
news:AD2B674E-3DB1-49A1-B889-(E-Mail Removed)...
> Trying to populate a listbox using additem (Access 2007 VBA). Whenever an
> item to be added contains a comma, it truncates it at that spot. Could it
> be
> that it mistakes the comma for a semicolon and expects it to belong to a
> different column?



 
Reply With Quote
 
FR
Guest
Posts: n/a
 
      2nd Oct 2008


"Douglas J. Steele" wrote:

> Try putting quotes around it.
>
> Instead of
>
> MyListbox.AddItem "1;A, B, C"
>
> try
>
>
> MyListbox.AddItem "1;""A, B, C"""
>
>
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "FR" <(E-Mail Removed)> wrote in message
> news:AD2B674E-3DB1-49A1-B889-(E-Mail Removed)...
> > Trying to populate a listbox using additem (Access 2007 VBA). Whenever an
> > item to be added contains a comma, it truncates it at that spot. Could it
> > be
> > that it mistakes the comma for a semicolon and expects it to belong to a
> > different column?

>
>

Thank you very much. Unfortunately the string comes from a recordset as
shown below

Do While Not rs.EOF
lbSelMem.AddItem rs.Fields(0).Value & ";" & rs.Fields(21).Value
rs.MoveNext
Loop

Fields(21) contains the string with the comma. I tested it by adding extra
columns to the listbox and sure enough text beyond the commas was put in
subsequent columns. I think this indicates that Access treats commas as if
they were semicolons. If so, is this a bug? And if so what is the procedure
to let Microsoft know?

Thanks again for your help.

 
Reply With Quote
 
OssieMac
Guest
Posts: n/a
 
      3rd Oct 2008
I am sure that Douglas is right. It is just how you use them. In your case
try inserting the double quote like this with the chr(34).

lbSelMem.AddItem chr(34) & rs.Fields(0).Value & chr(34) & ";" & chr(34) &
rs.Fields(21).Value & chr(34)

I assume that using the semi colon that you want two columns.

--
Regards,

OssieMac


"FR" wrote:

>
>
> "Douglas J. Steele" wrote:
>
> > Try putting quotes around it.
> >
> > Instead of
> >
> > MyListbox.AddItem "1;A, B, C"
> >
> > try
> >
> >
> > MyListbox.AddItem "1;""A, B, C"""
> >
> >
> >
> > --
> > Doug Steele, Microsoft Access MVP
> > http://I.Am/DougSteele
> > (no private e-mails, please)
> >
> >
> > "FR" <(E-Mail Removed)> wrote in message
> > news:AD2B674E-3DB1-49A1-B889-(E-Mail Removed)...
> > > Trying to populate a listbox using additem (Access 2007 VBA). Whenever an
> > > item to be added contains a comma, it truncates it at that spot. Could it
> > > be
> > > that it mistakes the comma for a semicolon and expects it to belong to a
> > > different column?

> >
> >

> Thank you very much. Unfortunately the string comes from a recordset as
> shown below
>
> Do While Not rs.EOF
> lbSelMem.AddItem rs.Fields(0).Value & ";" & rs.Fields(21).Value
> rs.MoveNext
> Loop
>
> Fields(21) contains the string with the comma. I tested it by adding extra
> columns to the listbox and sure enough text beyond the commas was put in
> subsequent columns. I think this indicates that Access treats commas as if
> they were semicolons. If so, is this a bug? And if so what is the procedure
> to let Microsoft know?
>
> Thanks again for your help.
>

 
Reply With Quote
 
FR
Guest
Posts: n/a
 
      3rd Oct 2008


"OssieMac" wrote:

> I am sure that Douglas is right. It is just how you use them. In your case
> try inserting the double quote like this with the chr(34).
>
> lbSelMem.AddItem chr(34) & rs.Fields(0).Value & chr(34) & ";" & chr(34) &
> rs.Fields(21).Value & chr(34)
>
> I assume that using the semi colon that you want two columns.


It worked!! You were absolutely right and I am most grateful
>
> --
> Regards,
>
> OssieMac
>
>
> "FR" wrote:
>
> >
> >
> > "Douglas J. Steele" wrote:
> >
> > > Try putting quotes around it.
> > >
> > > Instead of
> > >
> > > MyListbox.AddItem "1;A, B, C"
> > >
> > > try
> > >
> > >
> > > MyListbox.AddItem "1;""A, B, C"""
> > >
> > >
> > >
> > > --
> > > Doug Steele, Microsoft Access MVP
> > > http://I.Am/DougSteele
> > > (no private e-mails, please)
> > >
> > >
> > > "FR" <(E-Mail Removed)> wrote in message
> > > news:AD2B674E-3DB1-49A1-B889-(E-Mail Removed)...
> > > > Trying to populate a listbox using additem (Access 2007 VBA). Whenever an
> > > > item to be added contains a comma, it truncates it at that spot. Could it
> > > > be
> > > > that it mistakes the comma for a semicolon and expects it to belong to a
> > > > different column?
> > >
> > >

> > Thank you very much. Unfortunately the string comes from a recordset as
> > shown below
> >
> > Do While Not rs.EOF
> > lbSelMem.AddItem rs.Fields(0).Value & ";" & rs.Fields(21).Value
> > rs.MoveNext
> > Loop
> >
> > Fields(21) contains the string with the comma. I tested it by adding extra
> > columns to the listbox and sure enough text beyond the commas was put in
> > subsequent columns. I think this indicates that Access treats commas as if
> > they were semicolons. If so, is this a bug? And if so what is the procedure
> > to let Microsoft know?
> >
> > Thanks again for your help.
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listbox problem Paul Microsoft Access VBA Modules 3 17th Mar 2009 07:06 AM
Moving listbox item from listbox to listbox Kevin Quigley Microsoft Dot NET 2 2nd Jun 2004 11:34 AM
re: listbox + xp + problem nolz Microsoft Access Forms 0 5th Dec 2003 05:14 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Microsoft Excel Programming 0 22nd Oct 2003 12:46 AM
Problem with Listbox Yogen Reddy Microsoft Dot NET Framework Forms 2 20th Oct 2003 05:49 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:20 AM.