A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

" - Quotes



 
 
Thread Tools Display Modes
  #1  
Old September 30th, 2007, 09:55 AM posted to microsoft.public.access.forms
sc
external usenet poster
 
Posts: 41
Default " - Quotes

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
  #2  
Old September 30th, 2007, 11:46 AM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default " - Quotes

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)


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


"SC" wrote in message
...
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



  #3  
Old September 30th, 2007, 09:40 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 1,164
Default " - Quotes

In ,
SC wrote:
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


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


  #4  
Old October 1st, 2007, 04:51 PM posted to microsoft.public.access.forms
sc
external usenet poster
 
Posts: 41
Default " - Quotes

Thanks

"Douglas J. Steele" wrote:

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)


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


"SC" wrote in message
...
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




  #5  
Old October 1st, 2007, 04:51 PM posted to microsoft.public.access.forms
sc
external usenet poster
 
Posts: 41
Default " - Quotes

You are 100% correct. The text box should remain unbound. I made this change.

"Dirk Goldgar" wrote:

In ,
SC wrote:
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


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)



 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:58 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.