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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|