By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,206 Members | 1,035 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,206 IT Pros & Developers. It's quick & easy.

custom message box

P: n/a
Hi Gurus

I am trying to make a custom message box with a dialog form.

Here is how I would like to do it:
1- anywhere in the database, in any procedure, I call the function that
opens a dialog form
2- users clicks on a button in the custom form
3- answer from user is passed back to original procedure (e.g. whether
the answer was Yes or No).

I can do all of this but I can not pass the answer (the click of a button)
back to the original function (3).

Any suggestions?

Thank you

Nicolaas
Nov 13 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
WindAndWaves wrote:
Hi Gurus

I am trying to make a custom message box with a dialog form.

Here is how I would like to do it:
1- anywhere in the database, in any procedure, I call the function that
opens a dialog form
2- users clicks on a button in the custom form
3- answer from user is passed back to original procedure (e.g. whether
the answer was Yes or No).

I can do all of this but I can not pass the answer (the click of a button)
back to the original function (3).

Any suggestions?

Thank you

Nicolaas

I think I might be a bit simplistic here but perhaps this is all you need:

Dim Response as int

Response = Msgbox("Ask user a question",vbYesNo,"TestMsg")

IF Response = vbYes then

'Do stuff

Else

'Do sumfin else

end if

OR THIS WORKS TOO*******

IF Msgbox("Ask user a question",vbYesNo,"TestMsg") = vbYes then

'Do stuff

Else

'Do sumfin else

end if
Nov 13 '05 #2

P: n/a
On Wed, 23 Jun 2004 11:14:23 +1200, "WindAndWaves" <ac****@ngaru.com> wrote:
Hi Gurus

I am trying to make a custom message box with a dialog form.

Here is how I would like to do it:
1- anywhere in the database, in any procedure, I call the function that
opens a dialog form
2- users clicks on a button in the custom form
3- answer from user is passed back to original procedure (e.g. whether
the answer was Yes or No).

I can do all of this but I can not pass the answer (the click of a button)
back to the original function (3).

Any suggestions?

Thank you

Nicolaas


A dialog form will halt all code execution (except code in the dialog form itself) until the form is closed or hidden.
The method I use for returning a value from a dialog form is to hide the form rather than close it. This will allow code
execution to continue in the calling routine, but the values from the hidden dialog form are still available. Your
calling function grabs the value(s) it needs from the dialog and then closes the form.
eg
DoCmd.OpenForm "frmMyDialog", , , , , acDialog
'code execution stops here

'when the dialog form is hidden execution resumes
vSomeVariable = Forms!frmMyDialog!SomeControl

'now close the dialog form
DoCmd.Close acForm, "frmMyDialog"

The code behind your "Close" button on the dialog form would be -
Me.Visible = False
Wayne Gillespie
Gosford NSW Australia
Nov 13 '05 #3

P: n/a
Do you know you can easily do this with a messagebox:

Dim MsgStr As String
DimTitleStr As String
MsgStr = "My Message"
TitleStr = "Caption of Messagebox"
If MsgBox(MsgStr,vbYesNo,TitleStr) = vbYes Then
<Do This>
Else
<Do That>
End If

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

"WindAndWaves" <ac****@ngaru.com> wrote in message
news:B4*******************@news.xtra.co.nz...
Hi Gurus

I am trying to make a custom message box with a dialog form.

Here is how I would like to do it:
1- anywhere in the database, in any procedure, I call the function that
opens a dialog form
2- users clicks on a button in the custom form
3- answer from user is passed back to original procedure (e.g. whether
the answer was Yes or No).

I can do all of this but I can not pass the answer (the click of a button)
back to the original function (3).

Any suggestions?

Thank you

Nicolaas

Nov 13 '05 #4

P: n/a
I have done it with a message box in the past, but I am fussy and I do not
like the look of a message box (unless you know a way to change that).

Thank you
Nov 13 '05 #5

P: n/a
Hi Wayne

Thank you for that answer. That is very smart. It is quite unexpected
that:
a. you can hide a dialog form
b. code resumes when you hide it

Great solution.
Nov 13 '05 #6

P: n/a
"WindAndWaves" <ac****@ngaru.com> wrote in message
news:B4*******************@news.xtra.co.nz...
Hi Gurus

I am trying to make a custom message box with a dialog form.

Here is how I would like to do it:
1- anywhere in the database, in any procedure, I call the function that opens a dialog form
2- users clicks on a button in the custom form
3- answer from user is passed back to original procedure (e.g. whether
the answer was Yes or No).

I can do all of this but I can not pass the answer (the click of a button)
back to the original function (3).


When you open your custom dialog form do so using the acDialog windowmode
option.

DoCmd.OpenForm "frmMessageBox", acNormal, , , , acDialog

This causes the code in the calling routine to halt. When the user clicks
OK, (or Yes No or whatever), don't close the form - just hide it. This
allows the calling routine to continue. Since the message box form is still
open you can now read the value selected, (by setting a text box on the form
to receive the user selection for example). Now your calling code can close
the dialog.

In fact there's no requirement to close it - you could just leave it open
and hidden, and it will appear as normal the next time it's called.
Nov 13 '05 #7

P: n/a
thank you all for your help, i now have a great custom message box in
operation....
Nov 13 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.