Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / October 2007

Tip: Looking for answers? Try searching our database.

msgbox multiline

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chuck - 17 Oct 2007 05:48 GMT
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
John Nurick - 17 Oct 2007 06:50 GMT
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
[quoted text clipped - 13 lines]
>    'End If
>End Sub
--
John Nurick - Access MVP
Chuck - 17 Oct 2007 14:58 GMT
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.

> Hi Chuck,
>
[quoted text clipped - 48 lines]
> --
> John Nurick - Access MVP
fredg - 17 Oct 2007 15:52 GMT
> 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
[quoted text clipped - 52 lines]
>> --
>> John Nurick - Access MVP

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.
Signature

Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Chuck - 17 Oct 2007 23:51 GMT
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 =.............

> > 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
[quoted text clipped - 64 lines]
> All code processing will stop until you click one of the command
> buttons.
fredg - 18 Oct 2007 00:55 GMT
> 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*
[quoted text clipped - 4 lines]
>         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

Signature

Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Chuck - 18 Oct 2007 23:47 GMT
thanks Fred, that worked justed fine!

> > 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*
[quoted text clipped - 14 lines]
>
> If IsNull([Combo43]) AND IsNull([Combo53]) Then
NevilleT - 17 Oct 2007 07:02 GMT
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

> 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
[quoted text clipped - 13 lines]
>     'End If
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.