473,379 Members | 1,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 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 15221
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: One Handed Man \( OHM - Terry Burns \) | last post by:
When using a custom control. In order to check and see if values have changed one has to implement the IPostBackDataCollection interface. The values returned for the control seem to be simply a...
6
by: Nick Horrocks | last post by:
I have set up a custom error page for 404 errors. However the HTTP status code returned is 302 followed by 200, this causes search engines not to remove old pages from their index. How can I...
7
by: Adam | last post by:
Im trying to add an httphandler for all *.sgf file extensions. I have developed the handler, 1. installed it into the gac 2. added it to the machine.config: <httpHandlers> <add verb="*"...
5
by: Graham | last post by:
I have created a custom MembershipProvider called "LassieMembershipProvider" that derives from "MembershipProvider". This providor is located in a Businesslogic layer dll called...
2
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
6
by: Steve Amey | last post by:
Hi all I want to be able to throw a custom error up the call stack. I have looked around and it seems as though it's possible, but I can't get it to work :o( Below is some sample code. ...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
1
by: asharda | last post by:
I have a custom property grid. I am using custom property grid as I do not want the error messages that the propertygrid shows when abphabets are entered in interger fields. The custom property...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.