472,096 Members | 2,304 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,096 software developers and data experts.

custom message box

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
7 15007
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
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
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
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
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
"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
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.

Similar topics

21 posts views Thread by One Handed Man \( OHM - Terry Burns \) | last post: by
6 posts views Thread by Nick Horrocks | last post: by
6 posts views Thread by Steve Amey | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.