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  

Msgbox Code Syntax Error



 
 
Thread Tools Display Modes
  #1  
Old January 4th, 2010, 05:06 AM posted to microsoft.public.access.forms
Pamela
external usenet poster
 
Posts: 193
Default 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

  #2  
Old January 4th, 2010, 05:26 AM posted to microsoft.public.access.forms
.Len B
external usenet poster
 
Posts: 81
Default Msgbox Code Syntax Error

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



  #3  
Old January 4th, 2010, 05:32 AM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Msgbox Code Syntax Error

On Sun, 3 Jan 2010 21:06:01 -0800, 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


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]
  #4  
Old January 4th, 2010, 05:48 AM posted to microsoft.public.access.forms
.Len B
external usenet poster
 
Posts: 81
Default Msgbox Code Syntax Error

Hi John,
Any reason you used Chr(13) & Chr(10) rather than vbCrLf?
--
Len
__________________________________________________ ____
remove nothing for valid email address.
"John W. Vinson" wrote in message
...
| On Sun, 3 Jan 2010 21:06:01 -0800, 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
|
| 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]



  #5  
Old January 4th, 2010, 05:52 AM posted to microsoft.public.access.forms
Tom Wickerath
external usenet poster
 
Posts: 3,914
Default Msgbox Code Syntax Error

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

  #6  
Old January 4th, 2010, 06:51 AM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Msgbox Code Syntax Error

On Mon, 4 Jan 2010 15:48:14 +1000, ".Len B"
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]
  #7  
Old January 4th, 2010, 07:36 AM posted to microsoft.public.access.forms
.Len B
external usenet poster
 
Posts: 81
Default Msgbox Code Syntax Error

Glad to find its faster. Always looking to learn.

--
Len
__________________________________________________ ____
remove nothing for valid email address.
"John W. Vinson" wrote in message
...
| On Mon, 4 Jan 2010 15:48:14 +1000, ".Len B"

| 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]



 




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:13 AM.


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