AOB
Registered User.
- Local time
- Today, 22:52
- Joined
- Sep 26, 2012
- Messages
- 621
Hi,
Not sure if what I'm trying to do is simply outside the bounds of what Access 2013 can provide or if I'm just missing something stupid but hoping somebody can help...
I have a user form which acts as a method for users to create saved templates for emails. The form has a textbox (unbound) for the email body piece, set to Rich Text format so they can format the text as they want it and then save the contents to a record in the database so it can be retrieved again later. The corresponding field in the database is also set up as a Long Text with Rich Text format so it can handle the HTML output of the textbox value.
As part of this functionality, I'd like to allow users to insert formatted hyperlinks; that is, not just a raw link, but with a separate display text (in much the same way you could if creating an email in Outlook directly)
Obviously this is a problem as the Rich Text capabilities of a textbox in an Access form don't extend to this (you can type in a hyperlink address but you can't edit the hyperlink to set a separate display text)
To get around this, I wrote a function on the back of a command button to insert a hyperlink. When the user clicks the button, it opens a separate popup dialog where they can enter their link address as well as the text to display instead of the link. I then have some code that constructs the HTML for the formatted hyperlink, á la :
I appreciate that it's now not possible to click on the link in the textbox itself but that's fine, I don't really care about that, as long as the HTML is saved correctly then once it is transferred into the Outlook message, it should function.
Once the user is happy the email body is as it should be, there is a save button which saves the textbox value (i.e. the HTML) to the database.
Before anyone asks, the problem of the double-quotes is bypassed by replacing them with a placeholder character (e.g. |) when updating the record. And when an existing record is loaded back into the form, that placeholder is replaced back to the double-quotes.
This all works - here's where it gets weird though.... :banghead:
When debugging the code, I track the value in the textbox and the value in the database. Everything looks fine, the values are exactly as I would expect.
I close the form. I reopen it and load up a record. Again, everything looks fine; the HTML in the textbox value is exactly as it should be and the text appears perfectly in the form. Okay, the hyperlinks don't function if you click on them but the most important thing is, the HTML code is correct and they will function in an Outlook message.
I can close and reopen the form as many times as I like, everything works fine. I can navigate around other elements of the form, all is well.
If, however, I click back into the textbox - to make an edit somewhere else in the text - the hyperlink tags in the textbox value disappear?
So now, all of a sudden, they look like this :
It's like Access has decided to review the HTML, without being asked, seen the hyperlink tags and thought "nah, not having that" and just removed them, without prompt
To clarify, they are there when the record is initially loaded and the text in the textbox appears exactly as it should
So obviously if I then save the record again (with my unrelated edits), the hyperlink address is gone
This is obviously a major problem as it means users will have to manually reinsert any hyperlinks any and every time they decide to edit and save a template, which will be incredibly annoying.
Also, because the formatting and display text is retained, it's not immediately obvious what has happened from the interface - I know I'm going to have people asking me where their hyperlinks have gone in the final email output.
Has anybody any suggestions as to how to get around this problem or am I just running blindfold down a dark alley here?
Thanks in advance!
AOB
Not sure if what I'm trying to do is simply outside the bounds of what Access 2013 can provide or if I'm just missing something stupid but hoping somebody can help...
I have a user form which acts as a method for users to create saved templates for emails. The form has a textbox (unbound) for the email body piece, set to Rich Text format so they can format the text as they want it and then save the contents to a record in the database so it can be retrieved again later. The corresponding field in the database is also set up as a Long Text with Rich Text format so it can handle the HTML output of the textbox value.
As part of this functionality, I'd like to allow users to insert formatted hyperlinks; that is, not just a raw link, but with a separate display text (in much the same way you could if creating an email in Outlook directly)
Obviously this is a problem as the Rich Text capabilities of a textbox in an Access form don't extend to this (you can type in a hyperlink address but you can't edit the hyperlink to set a separate display text)
To get around this, I wrote a function on the back of a command button to insert a hyperlink. When the user clicks the button, it opens a separate popup dialog where they can enter their link address as well as the text to display instead of the link. I then have some code that constructs the HTML for the formatted hyperlink, á la :
The function then inserts this HTML into the existing HTML value for the textbox<font color="#5C83B4"><u><a href="http://www.somewebsite.com">Click here for your link</a></u></font>
I appreciate that it's now not possible to click on the link in the textbox itself but that's fine, I don't really care about that, as long as the HTML is saved correctly then once it is transferred into the Outlook message, it should function.
Once the user is happy the email body is as it should be, there is a save button which saves the textbox value (i.e. the HTML) to the database.
Before anyone asks, the problem of the double-quotes is bypassed by replacing them with a placeholder character (e.g. |) when updating the record. And when an existing record is loaded back into the form, that placeholder is replaced back to the double-quotes.
This all works - here's where it gets weird though.... :banghead:
When debugging the code, I track the value in the textbox and the value in the database. Everything looks fine, the values are exactly as I would expect.
I close the form. I reopen it and load up a record. Again, everything looks fine; the HTML in the textbox value is exactly as it should be and the text appears perfectly in the form. Okay, the hyperlinks don't function if you click on them but the most important thing is, the HTML code is correct and they will function in an Outlook message.
I can close and reopen the form as many times as I like, everything works fine. I can navigate around other elements of the form, all is well.
If, however, I click back into the textbox - to make an edit somewhere else in the text - the hyperlink tags in the textbox value disappear?
So now, all of a sudden, they look like this :
Note that the "display text" is retained, as is the formatting around it - but the link tags and link address are purged?<font color="#5C83B4"><u>Click here for your link</u></font>
It's like Access has decided to review the HTML, without being asked, seen the hyperlink tags and thought "nah, not having that" and just removed them, without prompt
To clarify, they are there when the record is initially loaded and the text in the textbox appears exactly as it should
So obviously if I then save the record again (with my unrelated edits), the hyperlink address is gone
This is obviously a major problem as it means users will have to manually reinsert any hyperlinks any and every time they decide to edit and save a template, which will be incredibly annoying.
Also, because the formatting and display text is retained, it's not immediately obvious what has happened from the interface - I know I'm going to have people asking me where their hyperlinks have gone in the final email output.
Has anybody any suggestions as to how to get around this problem or am I just running blindfold down a dark alley here?
Thanks in advance!
AOB