msgbox multiline

G

Guest

Hi, I'm trying to have a message box return a 3 line message with 2 variables
passed from the form when the Go button is clicked. This is what i have so
far.
Also i would like to check 2 text boxes for Is not null value then i fire
the msgbox


Private Sub Go_Click()
Dim Answer As Integer
MsgBox ("You are changing Client" & vbCrLf _
& Me![First_Name] " " & Me![Last_Name] & vbCrLf _
& "to Address blah balh ", vbExclamation, vbYesNo)
'If Answer = vbYes Then
' MsgBox "you said Yes"
'Else
' Beep
'End If
End Sub
 
J

John Nurick

Hi Chuck,

I'd write it along these lines:

Const MSG_TITLE = "Confirm Change of Address"
Dim strMsg As String

strMsg = "You are changing Client " & vbCrLf _
& Me.First_Name.Value & " " & Me.Last_Name.Value & vbCrLf _
& "to Address blah blah"

If MsgBox(strMsg, vbExclamation + vbYesNo, MSG_TITLE) = vbYes Then
'user said yes

Else
'user said no

End If

Note that you have to add the vbExclamation and vbYesNo constants to
get a single value to pass to MsgBox().

For the text boxes: if you want to find out if a textbox is empty
(either Null or an empty string), use

If Len(Nz(Me.txtXXX.Value), "") = 0 Then

If you want to catch Nulls but allow empty strings (which seems
unlikely), use

If IsNull(Me.txtXXX.Value)



Hi, I'm trying to have a message box return a 3 line message with 2 variables
passed from the form when the Go button is clicked. This is what i have so
far.
Also i would like to check 2 text boxes for Is not null value then i fire
the msgbox


Private Sub Go_Click()
Dim Answer As Integer
MsgBox ("You are changing Client" & vbCrLf _
& Me![First_Name] " " & Me![Last_Name] & vbCrLf _
& "to Address blah balh ", vbExclamation, vbYesNo)
'If Answer = vbYes Then
' MsgBox "you said Yes"
'Else
' Beep
'End If
End Sub
 
G

Guest

Hi Chuck

if the text box is called something like txtInput then you can use something
like this

dim strMsg as String

if is null(strInput) then
strMsg = "Please put something in the text box."
msgbox strMsg, vbCritical, "No Input"
end if

For the Go_Click try this:

Private Sub Go_Click()
Dim Answer As Integer

Answer = MsgBox ("You are changing Client" & vbCrLf & _
Me![First_Name] & " " & Me![Last_Name] & vbCrLf & _
" to Address blah balh ", vbExclamation, vbYesNo)
If Answer = vbYes Then
MsgBox "you said Yes"
Else
Beep
End If

End Sub
 
G

Guest

Hey thanks John, that worked well. Is there a way now to position the msgbox
somewhere different on the form has it is hiding some of the information on
the form when the box pops up.

John Nurick said:
Hi Chuck,

I'd write it along these lines:

Const MSG_TITLE = "Confirm Change of Address"
Dim strMsg As String

strMsg = "You are changing Client " & vbCrLf _
& Me.First_Name.Value & " " & Me.Last_Name.Value & vbCrLf _
& "to Address blah blah"

If MsgBox(strMsg, vbExclamation + vbYesNo, MSG_TITLE) = vbYes Then
'user said yes

Else
'user said no

End If

Note that you have to add the vbExclamation and vbYesNo constants to
get a single value to pass to MsgBox().

For the text boxes: if you want to find out if a textbox is empty
(either Null or an empty string), use

If Len(Nz(Me.txtXXX.Value), "") = 0 Then

If you want to catch Nulls but allow empty strings (which seems
unlikely), use

If IsNull(Me.txtXXX.Value)



Hi, I'm trying to have a message box return a 3 line message with 2 variables
passed from the form when the Go button is clicked. This is what i have so
far.
Also i would like to check 2 text boxes for Is not null value then i fire
the msgbox


Private Sub Go_Click()
Dim Answer As Integer
MsgBox ("You are changing Client" & vbCrLf _
& Me![First_Name] " " & Me![Last_Name] & vbCrLf _
& "to Address blah balh ", vbExclamation, vbYesNo)
'If Answer = vbYes Then
' MsgBox "you said Yes"
'Else
' Beep
'End If
End Sub
 
F

fredg

Hey thanks John, that worked well. Is there a way now to position the msgbox
somewhere different on the form has it is hiding some of the information on
the form when the box pops up.

John Nurick said:
Hi Chuck,

I'd write it along these lines:

Const MSG_TITLE = "Confirm Change of Address"
Dim strMsg As String

strMsg = "You are changing Client " & vbCrLf _
& Me.First_Name.Value & " " & Me.Last_Name.Value & vbCrLf _
& "to Address blah blah"

If MsgBox(strMsg, vbExclamation + vbYesNo, MSG_TITLE) = vbYes Then
'user said yes

Else
'user said no

End If

Note that you have to add the vbExclamation and vbYesNo constants to
get a single value to pass to MsgBox().

For the text boxes: if you want to find out if a textbox is empty
(either Null or an empty string), use

If Len(Nz(Me.txtXXX.Value), "") = 0 Then

If you want to catch Nulls but allow empty strings (which seems
unlikely), use

If IsNull(Me.txtXXX.Value)


Hi, I'm trying to have a message box return a 3 line message with 2 variables
passed from the form when the Go button is clicked. This is what i have so
far.
Also i would like to check 2 text boxes for Is not null value then i fire
the msgbox


Private Sub Go_Click()
Dim Answer As Integer
MsgBox ("You are changing Client" & vbCrLf _
& Me![First_Name] " " & Me![Last_Name] & vbCrLf _
& "to Address blah balh ", vbExclamation, vbYesNo)
'If Answer = vbYes Then
' MsgBox "you said Yes"
'Else
' Beep
'End If
End Sub

If you need to position it somewhere special in your window you will
need to create your own unbound form as a message form. Include a
label with your message, and a command button, or 2, or 3, as needed
to react to the message and close the form.
You can then use the MoveSize method in the form's open or load event
and size and position it anywhere you want.
To display the message you would use
DoCmd.OpenForm. "FormName", , , , , acDialog

All code processing will stop until you click one of the command
buttons.
 
G

Guest

Hi , additionally, i want to check a 2nd combo box for null value before
executiing the msgbox. Can you help me with adding the 2nd combobox *combo53*


If IsNull([Combo43]) Then
MsgBox "Client Name OR New Address is not selected"
Me.[Combo43].SetFocus
Else
strMsg =.............


fredg said:
Hey thanks John, that worked well. Is there a way now to position the msgbox
somewhere different on the form has it is hiding some of the information on
the form when the box pops up.

John Nurick said:
Hi Chuck,

I'd write it along these lines:

Const MSG_TITLE = "Confirm Change of Address"
Dim strMsg As String

strMsg = "You are changing Client " & vbCrLf _
& Me.First_Name.Value & " " & Me.Last_Name.Value & vbCrLf _
& "to Address blah blah"

If MsgBox(strMsg, vbExclamation + vbYesNo, MSG_TITLE) = vbYes Then
'user said yes

Else
'user said no

End If

Note that you have to add the vbExclamation and vbYesNo constants to
get a single value to pass to MsgBox().

For the text boxes: if you want to find out if a textbox is empty
(either Null or an empty string), use

If Len(Nz(Me.txtXXX.Value), "") = 0 Then

If you want to catch Nulls but allow empty strings (which seems
unlikely), use

If IsNull(Me.txtXXX.Value)


On Tue, 16 Oct 2007 21:48:00 -0700, Chuck

Hi, I'm trying to have a message box return a 3 line message with 2 variables
passed from the form when the Go button is clicked. This is what i have so
far.
Also i would like to check 2 text boxes for Is not null value then i fire
the msgbox


Private Sub Go_Click()
Dim Answer As Integer
MsgBox ("You are changing Client" & vbCrLf _
& Me![First_Name] " " & Me![Last_Name] & vbCrLf _
& "to Address blah balh ", vbExclamation, vbYesNo)
'If Answer = vbYes Then
' MsgBox "you said Yes"
'Else
' Beep
'End If
End Sub

If you need to position it somewhere special in your window you will
need to create your own unbound form as a message form. Include a
label with your message, and a command button, or 2, or 3, as needed
to react to the message and close the form.
You can then use the MoveSize method in the form's open or load event
and size and position it anywhere you want.
To display the message you would use
DoCmd.OpenForm. "FormName", , , , , acDialog

All code processing will stop until you click one of the command
buttons.
 
F

fredg

Hi , additionally, i want to check a 2nd combo box for null value before
executiing the msgbox. Can you help me with adding the 2nd combobox *combo53*

If IsNull([Combo43]) Then
MsgBox "Client Name OR New Address is not selected"
Me.[Combo43].SetFocus
Else
strMsg =.............
** snipped **


Do you wish either one OR the other is Null?

If IsNull([Combo43]) Or IsNull([Combo53]) Then

Or both must be null?

If IsNull([Combo43]) AND IsNull([Combo53]) Then
 
G

Guest

thanks Fred, that worked justed fine!

fredg said:
Hi , additionally, i want to check a 2nd combo box for null value before
executiing the msgbox. Can you help me with adding the 2nd combobox *combo53*

If IsNull([Combo43]) Then
MsgBox "Client Name OR New Address is not selected"
Me.[Combo43].SetFocus
Else
strMsg =.............
** snipped **


Do you wish either one OR the other is Null?

If IsNull([Combo43]) Or IsNull([Combo53]) Then

Or both must be null?

If IsNull([Combo43]) AND IsNull([Combo53]) Then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top