" - Quotes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

I'm trying to display a note in a text box. The line of code is simply:

txtNote.ControlSource = "=" & Chr(34) & ListNotes.SelectedItem. & Chr(34)

the problem is that anytime the note itself has a " in it, it causes an
error. Are there any creative ways around this?

Thanks,

Steve
 
Use the Replace function to change any instance of a double quote in the
text to two instances of a double quote.

txtNote.ControlSource = "=" & Chr(34) & Replace(ListNotes.SelectedItem,
Chr(34), Chr(34) & Chr(34)) & Chr(34)
 
In
SC said:
Hi All,

I'm trying to display a note in a text box. The line of code is
simply:

txtNote.ControlSource = "=" & Chr(34) & ListNotes.SelectedItem. &
Chr(34)

the problem is that anytime the note itself has a " in it, it causes
an error. Are there any creative ways around this?

Doug gave you an answer that solves the problem with the quotes, but I'm
curious: is there a reason you're setting the text box's controlsource
expression, binding the text box on the fly to a static expression,
rather than leaving the text box unbound and just setting its value to
the text of the note? E.g.,

txtNote = ListNotes.SelectedItem
 
Thanks

Douglas J. Steele said:
Use the Replace function to change any instance of a double quote in the
text to two instances of a double quote.

txtNote.ControlSource = "=" & Chr(34) & Replace(ListNotes.SelectedItem,
Chr(34), Chr(34) & Chr(34)) & Chr(34)
 
You are 100% correct. The text box should remain unbound. I made this change.
 

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

Back
Top