Msgbox Code Syntax Error

I have a message box that I want to display in the OnEnter event of a List 
box simply to give instructions as to how the user is to enter the info.  My 
code for the Message box isn't working and I'm getting a syntax error - I 
also got an error that the system is expecting an "=" in the code.  I've 
researched it but can seem to see what I'm missing.  I only want an OK button 
on it and then to return focus to to the control to which the code is 
attached.  Here's the code:
Private Sub lbDamagedParts_Enter()
Me!Label23.Visible = True
Msgbox("For the following sections: (Chr(13))Damaged Parts, Unrelated Prior 
and Supp Items (Chr(13)) Select all that apply by holding as you click to 
select or unselect multiple entries",vbokonly,"Warning")
End Sub
Thanks so much!!
Pamela

0
Utf
1/4/2010 5:06:01 AM
access.forms 6864 articles. 2 followers. Follow

6 Replies
960 Views

Similar Articles

[PageSpeed] 19

Hi Pamela,
There are 2 MsgBox commands. One is a function, the other a statement.

You need the statement form.

 Msgbox  "For the following sections: (Chr(13))Damaged Parts, Unrelated 
Prior
 and Supp Items (Chr(13)) Select all that apply by holding as you click 
to
 select or unselect multiple entries",vbokonly,"Warning"

A function requires the = because it assigns a reply to a variable.
Response = MsgBox (parameters)

A statement just says "Show This"
MsgBox  parameter, parameter ...
-- 
Len
______________________________________________________
remove nothing for valid email address.
"Pamela" <Pamela@discussions.microsoft.com> wrote in message 
news:CFAB55B9-8184-4A40-9BEB-FC934061BDAE@microsoft.com...
|I have a message box that I want to display in the OnEnter event of a 
List
| box simply to give instructions as to how the user is to enter the 
info.  My
| code for the Message box isn't working and I'm getting a syntax error - 
I
| also got an error that the system is expecting an "=" in the code. 
I've
| researched it but can seem to see what I'm missing.  I only want an OK 
button
| on it and then to return focus to to the control to which the code is
| attached.  Here's the code:
| Private Sub lbDamagedParts_Enter()
| Me!Label23.Visible = True
| Msgbox("For the following sections: (Chr(13))Damaged Parts, Unrelated 
Prior
| and Supp Items (Chr(13)) Select all that apply by holding as you click 
to
| select or unselect multiple entries",vbokonly,"Warning")
| End Sub
| Thanks so much!!
| Pamela
|



0
Len
1/4/2010 5:26:55 AM
On Sun, 3 Jan 2010 21:06:01 -0800, Pamela <Pamela@discussions.microsoft.com>
wrote:

>I have a message box that I want to display in the OnEnter event of a List 
>box simply to give instructions as to how the user is to enter the info.  My 
>code for the Message box isn't working and I'm getting a syntax error - I 
>also got an error that the system is expecting an "=" in the code.  I've 
>researched it but can seem to see what I'm missing.  I only want an OK button 
>on it and then to return focus to to the control to which the code is 
>attached.  Here's the code:
>Private Sub lbDamagedParts_Enter()
>Me!Label23.Visible = True
>Msgbox("For the following sections: (Chr(13))Damaged Parts, Unrelated Prior 
>and Supp Items (Chr(13)) Select all that apply by holding as you click to 
>select or unselect multiple entries",vbokonly,"Warning")
>End Sub
>Thanks so much!!
>Pamela

There are two ways to use MsgBox. One is as a statement which does not return
a value:

MsgBox "Message", <optional operands>

The other is a function, which does:

iAns = MsgBox("Message", <optional operands>)

Since in this case you don't want the user to reply with Yes or No, try using
the statement syntax. I'm also correcting the use of Chr(13) - carriage return
- to Chr(13) & Chr(10) - carriage-return-line-feed, and some quote errors:

Msgbox "For the following sections:" & Chr(13) & Chr(10) & _
"Damaged Parts, Unrelated Prior and Supp Items" & Chr(13) & Chr(10) & _
"Select all that apply by holding as you click to select " & _
"or unselect multiple entries",vbokonly,"Warning"


-- 

             John W. Vinson [MVP]
0
John
1/4/2010 5:32:43 AM
Hi John,
Any reason you used Chr(13) & Chr(10) rather than vbCrLf?
-- 
Len
______________________________________________________
remove nothing for valid email address.
"John W. Vinson" <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in message 
news:41v2k5dq7suq81gl74gnkiaakftl3qp9pe@4ax.com...
| On Sun, 3 Jan 2010 21:06:01 -0800, Pamela 
<Pamela@discussions.microsoft.com>
| wrote:
|
| >I have a message box that I want to display in the OnEnter event of a 
List
| >box simply to give instructions as to how the user is to enter the 
info.  My
| >code for the Message box isn't working and I'm getting a syntax 
error - I
| >also got an error that the system is expecting an "=" in the code. 
I've
| >researched it but can seem to see what I'm missing.  I only want an OK 
button
| >on it and then to return focus to to the control to which the code is
| >attached.  Here's the code:
| >Private Sub lbDamagedParts_Enter()
| >Me!Label23.Visible = True
| >Msgbox("For the following sections: (Chr(13))Damaged Parts, Unrelated 
Prior
| >and Supp Items (Chr(13)) Select all that apply by holding as you click 
to
| >select or unselect multiple entries",vbokonly,"Warning")
| >End Sub
| >Thanks so much!!
| >Pamela
|
| There are two ways to use MsgBox. One is as a statement which does not 
return
| a value:
|
| MsgBox "Message", <optional operands>
|
| The other is a function, which does:
|
| iAns = MsgBox("Message", <optional operands>)
|
| Since in this case you don't want the user to reply with Yes or No, try 
using
| the statement syntax. I'm also correcting the use of Chr(13) - carriage 
return
| - to Chr(13) & Chr(10) - carriage-return-line-feed, and some quote 
errors:
|
| Msgbox "For the following sections:" & Chr(13) & Chr(10) & _
| "Damaged Parts, Unrelated Prior and Supp Items" & Chr(13) & Chr(10) & _
| "Select all that apply by holding as you click to select " & _
| "or unselect multiple entries",vbokonly,"Warning"
|
|
| -- 
|
|             John W. Vinson [MVP]



0
Len
1/4/2010 5:48:14 AM
Hi Pamela,

Try this form for a message box only. I used vbCrLf in place of Chr(13):

Sub lbDamagedParts_Enter()
On Error GoTo ProcError

Me!Label23.Visible = True
MsgBox "For the following sections: " & vbCrLf _
     & "Damaged Parts, Unrelated Prior and Supp Items" & vbCrLf & vbCrLf _
     & "Select all that apply by holding as you click to " _
     & "select or unselect multiple entries.", vbOKOnly, "Warning"

' Use this form if you need to return a result from the MsgBox function
' However, this is only appropriate if you have more than one choice, for 
example
' a Yes and a No button. Notice how the parentheses are included for the 
function:

'Dim intResult As Integer
'intResult = MsgBox("For the following sections: " & vbCrLf _
'     & "Damaged Parts, Unrelated Prior and Supp Items" & vbCrLf & vbCrLf _
'     & "Select all that apply by holding as you click to " _
'     & "select or unselect multiple entries.", vbOKOnly, "Warning")

ExitProc:
   Exit Sub
ProcError:
   MsgBox "Error " & Err.Number & " (" & Err.Description & ") " _
        & "in lbDamagedParts_Enter procedure."
   Resume ExitProc
End Sub


That said, it seems to me like your users could get really tired of having 
to dismiss this message box every time they needed to select items in the 
list box. 


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________

"Pamela" wrote:

> I have a message box that I want to display in the OnEnter event of a List 
> box simply to give instructions as to how the user is to enter the info.  My 
> code for the Message box isn't working and I'm getting a syntax error - I 
> also got an error that the system is expecting an "=" in the code.  I've 
> researched it but can seem to see what I'm missing.  I only want an OK button 
> on it and then to return focus to to the control to which the code is 
> attached.  Here's the code:
> Private Sub lbDamagedParts_Enter()
> Me!Label23.Visible = True
> Msgbox("For the following sections: (Chr(13))Damaged Parts, Unrelated Prior 
> and Supp Items (Chr(13)) Select all that apply by holding as you click to 
> select or unselect multiple entries",vbokonly,"Warning")
> End Sub
> Thanks so much!!
> Pamela
0
Utf
1/4/2010 5:52:01 AM
On Mon, 4 Jan 2010 15:48:14 +1000, ".Len B" <gonehome@internode0.on0.net>
wrote:

>Hi John,
>Any reason you used Chr(13) & Chr(10) rather than vbCrLf?

Habit... you're right, the defined constant is clearer and faster!
-- 

             John W. Vinson [MVP]
0
John
1/4/2010 6:51:01 AM
Glad to find its faster. Always looking to learn.

-- 
Len
______________________________________________________
remove nothing for valid email address.
"John W. Vinson" <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in message 
news:ut33k5ptlr6t4q73iganh3gf0upupfelrk@4ax.com...
| On Mon, 4 Jan 2010 15:48:14 +1000, ".Len B" 
<gonehome@internode0.on0.net>
| wrote:
|
| >Hi John,
| >Any reason you used Chr(13) & Chr(10) rather than vbCrLf?
|
| Habit... you're right, the defined constant is clearer and faster!
| -- 
|
|             John W. Vinson [MVP]



0
Len
1/4/2010 7:36:53 AM
Reply:

Similar Artilces:

Need Syntax for "AND" to Evaluate 2 Cells
I need to evaluate 2 cells while inside an "Private Sub Worksheet_SelectionChange(ByVal Target As Range)". I thought AND would work but I cannot get it to work; I receive a syntax error on the AND(Range... line. Can someone please provide me the proper syntax to evaluate the 2 cells? Here's my code... Private Sub Worksheet_SelectionChange(ByVal Target As Range) If ActiveSheet.Name = "Sheet1" Then And(Range("I3") <> "", Range("K4") = "") Then Range("K4") = Range("K3") End...

Is it possible to generate non-technical schema validation errors?
With the 1.0 Framework, I've worked out using the XmlValidatingReader. Since I'm using the validation errors as feedback to the end user, I'm hoping to get away from techy messages such as "The 'http://tempuri.org/XMLFile1.xsd:MaxDependents' element has an invalid value according to its data type. An error occurred at file:///c:/work/prodika/main/code/apps/schemavalidation/XMLFile1.xml(8, 25)." and go with a user friendly message of "Max Dependents must be between 0 and 10". I've scoured the newsgroups, MSDN and docs for creating custom valid...

Force a page break in code
I need to force a page break in the Detail_OnFormat Event when a value changes. How do I do that? Thanks, Bill Bill wrote: > I need to force a page break in the Detail_OnFormat > Event when a value changes. How do I do that? > > Thanks, > Bill Insert a PageBreak control from the ToolBox bar at the desired location. Even though such a control is never "visible" other than in design view they do still have a Visible property. That property effectively turns on and off the PageBreak so you can minipulate that in your code. -- Rick Brandt, Microsoft Access MVP...

Upgrading
I want to upgrade from Microsoft Money Financial Suite OEM Edition Version 11.0 to latest version but on trying to open the money file in Microsoft Money 2007 I get the following error message: File was created by an incompatible version Question 1: As the old version was pre-loaded into the Computer when I bought it in India, I don't know which country US/Canada/UK/Australia this software belongs to. So how can I confirm which country is it for? Question 2: And, how can I upgrade it to a version of Money from US or UK. -- Kapil ...

VBA Error Message "Compile Error...."
I used a macro from Ron's website to mail each worksheet to the email address in cell a1. I ran this macro and it worked perfectly for one workbook BUT... when I tried to use it for another workbook I got the follwing error message "Microsoft Visual Basic Compile Error Can't find project or library Ok Help". Help me please... do I have to check some more references in the VBA tools? Thanks, Steve Hi Steve Have you set the reference to Outlook in that other workbook also ? You must do that in every workbook or you can use Late binding. See my site for a example --...

Error 1606 Money Service Pack 2002
I have tried all of the suggested fixes that I've seen on these boards for the error 1606. I now have no money program, I can not reinstall the money program and the error still pops up in my Turbo Tax and it is driving me crazy! I can not delete the service pack from the add or remove programs applet. I would very much like to finish the taxes before the 15Th. Does someone know what is going on? I've deleted registry keys, done clean boots, tried to eliminate every vestige of the program that can be found yet, when I try to reinstall from the disk, I'm stymied by Error...

OWA Error for http links
links inside a message body always generate an asp redirect code that does not execute at all thus giving an http 500 error - page not found. Example on a link to http://www.nightlight.org within a mail body. http://orange/exchweb/bin/redir.asp? URL=http://www.nightlight.org/ Exchange Server 2003 running on Server 2000 SP4 PLease help. ...

Error 2455 Closing Access 2007 database with form open
I have a form with a subform that is requeried when you select a new key for the main form from a combo box. Everything works fine - usually. But sometimes if you have the form open when you close the database down you get the following error message (twice) in a pop up. You say OK (twice) and the database closes OK "2455 you entered an expression that has an invalid reference to the property form/report" If I close the form before the database I never get the error. If I do not touch the form before you close the database I don't get the error. If I update a field by t...

Error message #5
Excel 2000 - Try to save workbook as Excel 97 - 2000 & 5.0/95. Receive error message " An error occurred and this feature is no longer functioning properly. Would you like to repair the feature now?" If you say YES I get an "Internal Error 2709." Does anyone know how to determine what feature the error message is referring to and how to repair the issue randy ...

Error creating new task
Error .. "Could not complete operation. One or more parameter values are not vaild" ...

How do add another code to a current one?
I have this following code to make the rows changed based on the critea in column 16, and I need add A "Red, Yellow, Green" for status to only one column 30 at the end of the spreadsheet. How do I add another code? I keep getting an error.. Private Sub Worksheet_Change(ByVal Target As Range) Dim c As Range, clr As Long For Each c In Target.Cells If c.Column = 16 Then Select Case c.Value Case "Analyze": clr = RGB(204, 255, 255) Case "Build ": clr = RGB(204, 255, 255) Case ...

Public folder issue, "messaging interface has returned an unknown error"
I'm running a SBS2003 domain and just added a public folder and a customized form for entry into the public folder. All of our clients (all XP Pro, Outlook 2003 with all updates) can get to that folder and use the form without any difficulty except for one. On one computer I get the classic "The messaging interface has returned an unknown error. If the problem persists, restart Outlook." error message. I have tried a repair install, no change. I have tried making a new profile, no change. I have tried adding / removing his PST file (currently he's not even using a pst file...

Changing fonts in msgbox
If i create a msgbox with a prompt, can i change or modify the font of the text in the msgbox ?? Ditto Inputbox.... thanks! ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ You can't change the font used in a MsgBox. This limitation is one of the prices you pay for the simplicity of a MsgBox. If you need to change the font, you need to create a UserForm and display that form instead of using a MsgBox. -- Cordially, Chip Pearson Microsoft MVP - Excel www.cpears...

Outlook 2007 error event id: 35
Per hour i receive about 12'000 of these errors in the event viewer on my vista laptop. And usualy my outlook at some point just goes into the "not responding" mode. Then I have to kill the process from the task manager to be able to reopen outlook just to see it freeze again after a couple of seconds. I tried the whole stop indexing service and reinstall index service procedure to no avail. Does anyone else have a solution to this very anoying problem? Fred putzhilfe@gmail.com <putzhilfe@gmail.com> wrote: > Per hour i receive about 12'000 of these errors in the...

Problem with vba code to export query result in excel
Hi, I have a access report that exports to excel with click of a button after choosing parameters. This works well. However I have to modify couple of fields to utilize formula in the export module. I am not sure how to do this. I am writing the above code which seems to cause problem. I appreciate any help to resolve this issue. Thanks. Code: If lngColumn = 12 Then xlc.Offset(0, lngColumn).Value = =([UnitPrice]*[OriginalShippedQty])/1000 End If It seems the fields UnitPrice and OrigianalShippedQty are not being recognized here Jack wrote: >Hi, >I have a acces...

Word 2007 Error message
Hello, I'm currently using Works Suite 2006. I am attempting to intall the Word 2007 upgrade to no avail as I receiving the following error message: SET-UP ERROR D:\wordR.ww\osetup.DLL digital signature does not validate or is not present I would appreciate any advice and/or suggestions so that I can install Word 2007. Ciao, Jerry Sorry Jerry but this is Microsoft Access forum. You need to post this question to a different group to find any useful help. "Jerry T" <Jerry T@discussions.microsoft.com> wrote in message news:B45E64C3-D080-405E-9159-CB3E7F73AFFC@micr...

Error message when signing into Great Plains
I have a problem when setting up MS Great Plain. When I log into a company (E.G. company ABC), I receive an error message says "Decrypt Job Cost Creation Failed", I press OK, and the program just continues to run. Is there anyone know what is this message is about and how to resolve this problem?? Thank you very much This error is generated by the Wennsoft Products dictionary. Most times it relates to not installing the Wennsoft product from the SETUP.EXE. This is necessary as it installs and registers a couple DLL files, specifically WSREGKEYM.DLL and WSWRAPPER.DLL Refer to th...

Personal Folder Error when opening Outook 2002
When opening Outlook 2002, I receive the message that the Personal folder was not closed properly and needs to be checked. I allow the check to run, and all is fine. But this error message reappears after I close and reopen Outlook. Please Reply. thanks. ...

Code about setting Y Axes scale.
I couldn't understand the lines between 35-42, why he thought the dbMinScale after the change is the one he want. What the logic of this code section. Any one who could understand please help me. thanks in advance!:) Private Sub USP_SetYAxesScal(ByVal i_strWSName As String, ByVal i_strChartName As String, Optional ByVal i_intDecimal As Integer = 2) Dim dbMaxScale As Double, dbMinScale As Double, i As Integer, j As Integer Dim xTargetChart As Chart, vTemp() As Variant, blnInit As Boolean, dbMax As Double, dbMin As Double 1 On Error Resume Next 'get max/m...

"could not fetch new headers " ERROR
i get the error " could not fetch new headers in the inbox of IMA server.The operation was cancelled ", while using my outlook 2000 o win98se mach. config: smtp/imap thro internet mail a/c option pl try to provide solutions to it. the error message pops up say every 5 min whenever outlook is on. thnks n regards gir ----------------------------------------------- ~~ Message posted from http://www.ExcelTip.com ~~View and post usenet messages directly from http://www.ExcelForum.com aggiridharan <aggiridharan.149yy0@outlookforum.com> wrote: > i get the error " coul...

absolutely cannot resolve timeout error
OL 2002 (10.6515.6626) SP3 Win XP HE Follow-up to: *microsoft.public.outlook* (this message is cross-posted to the newsgroups that appear in the headers. To reply, just click "Reply" in news client and it will go to the follow-up newsgroup *microsoft.public.outlook*, where u can follow the thread. Thanks.) Hi, I am constantly receiving error message: Task 'smtp server name - Sending and Receiving' reported error (0x8004210A): 'The operation timed out waiting for a response from the receiving (POP) server. If you continue to receive this message, contact your s...

Help with a code
I have these code and it works find: but i also want to use it for different culumn within the same sheet. how do i add Column D with different target? meaning "S" for Study and "B" for books and s on... and maybe adding a Msg box to it that will only allow the Letters specify.. thank you in advance.. Private Sub Worksheet_Change(ByVal Target As Range) If Target = "" Then Exit Sub If Target.Count > 1 Then Exit Sub If Not Intersect(Target, Range("c6:c50")) Is Nothing Then If UCase(Target) = "C" Then Target = "Contribution" El...

Excel Number Format Codes
I can't figure out how to format numbers so that when you type 3220 it will look like 32.20 kinda like how you can enter numbers on an adding machine. I would greatly appreciate this number format code. Thank you. -- 1:~ Hi, I think you want to go Tools | Options | Edit | Fixed Decimals - 2. That will divide all the numbers you enter by 100. You will also have to format the row or column to display 2 decimals. Select the cells or range, right mouse click, format cells, numbers, 2 decimals. Hope that helps. Best regards, Kevin "MBB" <MBB@discussions.microsoft.com> w...

Error trying to make an account default
I have a new computer and my outlook 2003 is not letting me assign a default account to send and receive. I get this error: "The Specicied Account could not be found. It might have been deleted." I have four accounnts setup and have tried removing the accounts and recreating them and still get the error. when the account has been made, it tests fine. None of the four can be made default. Thanks in Advance! ...

zip code help! #2
thanks for the help !!!!!!!! It worke -- cbender ----------------------------------------------------------------------- cbender3's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1556 View this thread: http://www.excelforum.com/showthread.php?threadid=27126 ...