Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 28th, 2006, 12:55 PM
Authorized User
 
Join Date: Feb 2006
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default format variable in msgbox

Is there a way to format variables when they are referenced in the msgbox function. It is hard to distinguish the value of the variable from the other words. I would like to format them in italics or make them bold or even a different color.

As an example the returned value of the variable is "BE Cap Retro Adjust Limit." I would like the message to look something like this.

You have selected BE Cap Retro Adjust Limit twice

Thanks,
Scott
__________________
ScottP
 
Old February 28th, 2006, 01:47 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   There really is no good way to do this using VBA since it uses a default system font. You could change that, but all your messages would be italicized.

   The best way to do this is to create a form that you use for messages with a text box and the buttons you want, like OK. Then format the font in the text box(es) on the fly, or make them all italicized. You will need to do this at runtime or the On Current event of the form.

HTH


mmcdonal
 
Old February 28th, 2006, 02:31 PM
Authorized User
 
Join Date: Feb 2006
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the quick reply. I think using a form will work just fine. Thanks for your help.

Scott
 
Old March 2nd, 2006, 09:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Try one of these two approaches:

1) Emphasis with upper case

MsgBox "You have selected " & UCase(Me.txtVariable) & " twice.", vbExclamation, "Duplicate!"

or

2) Bold the first line of your message box only.

Eval ("MsgBox ('" & Me.txtVariable & "@@has been selected twice.'," & vbExclamation & ",'Duplicate!')")

Take special note of where the single and double quotes are. The @ signs will not show in the message box. Everything after them will be normal and on a new line. Everything before them will be bold and on the first line.

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old March 2nd, 2006, 09:15 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Oh, I'm using Access XP (2002) on Windows 2000 NT. I have no idea if option 2 will work with other Access/Windows combinations!
 
Old March 3rd, 2006, 05:42 PM
Authorized User
 
Join Date: Feb 2006
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Greg, I used the second option and it works, although I am using Access XP also.

Thanks again for your help.

Scott





Similar Threads
Thread Thread Starter Forum Replies Last Post
Msgbox Help darrenb Access VBA 2 June 8th, 2007 12:53 AM
MsgBox prabodh_mishra Pro VB 6 1 December 29th, 2006 11:51 AM
msgbox Ramakrishna.G General .NET 3 September 14th, 2004 02:17 AM
help with Msgbox helmekki Excel VBA 2 June 25th, 2004 08:24 AM
msgbox bph Access VBA 2 February 6th, 2004 03:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.