Customizing MsgBox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

MsgBox is very useful but is limited by the selection of buttons available.
In the context in which I am using it, ‘Retry’ and ‘Proceed’ would be the
ideal buttons to display, making ‘Retry’ and ‘Cancel’ look a distinctly odd
combination. Is there a way of changing the button captions? (I would be
happy to service ‘Proceed’ as vbCancel since the user would be unaware of the
stratagem.)

One possible alternative is to create a form with the necessary message text
and buttons of choice but the difficulty then is to pause the principal form
VBA while the button selection is being made. A common solution is to
transfer any subsequent code to the buttons on the second form, which can
thus be used to perform the required functions, according to the selection
made, including closure of the principal form. However, ‘Retry’ involves
rerunning the principal form code, making iteration from the secondary form
quite difficult.

Has anyone got any good ideas?
 
You can create a form as a meesage box, and when you open it using the
OpenForm command line, add to it acDialog, that will stop the code until you
close the form

Docmd.OpenForm "FormName", , , , ,acDialog
 
Hi there,
I'm not expert in Access but as far as I'm aware you may not customise the
name of the buttons for a MsgBox (beyond selecting one of the preset options).
However, if you should decide to design your own form you can specify that
it's a dialogue box from within the code that's calling the OpenForm method.
This would halt the procedure until one or other button is clicked.
The code would be something like:

DoCmd.OpenForm "frmName", , , , , acDialog

Hope this helps,

Lee
 
MsgBox is very useful but is limited by the selection of buttons available.
In the context in which I am using it, ¡Retry¢ and ¡Proceed¢ would be the
ideal buttons to display, making ¡Retry¢ and ¡Cancel¢ look a distinctly odd
combination. Is there a way of changing the button captions? (I would be
happy to service ¡Proceed¢ as vbCancel since the user would be unaware of the
stratagem.)

One possible alternative is to create a form with the necessary message text
and buttons of choice but the difficulty then is to pause the principal form
VBA while the button selection is being made. A common solution is to
transfer any subsequent code to the buttons on the second form, which can
thus be used to perform the required functions, according to the selection
made, including closure of the principal form. However, ¡Retry¢ involves
rerunning the principal form code, making iteration from the secondary form
quite difficult.

Has anyone got any good ideas?

There is no method available to change the MsgBox button captions.

Create your own form as suggested in your second paragraph.
You are mistaken about not being able to pause code execution until
the form is acted upon.

Have an unbound text control on the form.
Code the Proceed Command button:
Me![TextControlName] = 1
Me.Visible = False

Code the Retry Command Button:
Me![TextControlName] = 2
Me.Visible = False

Then in the code used to open the message form, use:

DoCmd.OpenForm "MessageForm", , , , , acDialog
If forms!MessageForm!TextControlName = 1 Then
' Do the Proceed stuff
Else
' Do the Retry stuff
End If
DoCmd.Close acForm, "MessageForm"

All code processing will stop until one or the other button is
clicked.
 
Fred,

I know this isn't 'my' thread - I just replied above - but I'm interested in
your response as I can't see why you need to create the two hidden text boxes
when the form is opened as acDialog. Wouldn't you just add the proceed code
to the onclick event of the Proceed button etc...?
Just curious. Or am I missing something here?! :-)

Lee

fredg said:
MsgBox is very useful but is limited by the selection of buttons available.
In the context in which I am using it, ʽRetryʼ and ʽProceedʼ would be the
ideal buttons to display, making ʽRetryʼ and ʽCancelʼ look a distinctly odd
combination. Is there a way of changing the button captions? (I would be
happy to service ʽProceedʼ as vbCancel since the user would be unaware of the
stratagem.)

One possible alternative is to create a form with the necessary message text
and buttons of choice but the difficulty then is to pause the principal form
VBA while the button selection is being made. A common solution is to
transfer any subsequent code to the buttons on the second form, which can
thus be used to perform the required functions, according to the selection
made, including closure of the principal form. However, ʽRetryʼ involves
rerunning the principal form code, making iteration from the secondary form
quite difficult.

Has anyone got any good ideas?

There is no method available to change the MsgBox button captions.

Create your own form as suggested in your second paragraph.
You are mistaken about not being able to pause code execution until
the form is acted upon.

Have an unbound text control on the form.
Code the Proceed Command button:
Me![TextControlName] = 1
Me.Visible = False

Code the Retry Command Button:
Me![TextControlName] = 2
Me.Visible = False

Then in the code used to open the message form, use:

DoCmd.OpenForm "MessageForm", , , , , acDialog
If forms!MessageForm!TextControlName = 1 Then
' Do the Proceed stuff
Else
' Do the Retry stuff
End If
DoCmd.Close acForm, "MessageForm"

All code processing will stop until one or the other button is
clicked.
 
Fred,

I know this isn't 'my' thread - I just replied above - but I'm interested in
your response as I can't see why you need to create the two hidden text boxes
when the form is opened as acDialog. Wouldn't you just add the proceed code
to the onclick event of the Proceed button etc...?
Just curious. Or am I missing something here?! :-)

Lee

fredg said:
MsgBox is very useful but is limited by the selection of buttons available.
In the context in which I am using it, ʽRetryʼ and ʽProceedʼ would be the
ideal buttons to display, making ʽRetryʼ and ʽCancelʼ look a distinctly odd
combination. Is there a way of changing the button captions? (I would be
happy to service ʽProceedʼ as vbCancel since the user would be unaware of the
stratagem.)

One possible alternative is to create a form with the necessary message text
and buttons of choice but the difficulty then is to pause the principal form
VBA while the button selection is being made. A common solution is to
transfer any subsequent code to the buttons on the second form, which can
thus be used to perform the required functions, according to the selection
made, including closure of the principal form. However, ʽRetryʼ involves
rerunning the principal form code, making iteration from the secondary form
quite difficult.

Has anyone got any good ideas?

There is no method available to change the MsgBox button captions.

Create your own form as suggested in your second paragraph.
You are mistaken about not being able to pause code execution until
the form is acted upon.

Have an unbound text control on the form.
Code the Proceed Command button:
Me![TextControlName] = 1
Me.Visible = False

Code the Retry Command Button:
Me![TextControlName] = 2
Me.Visible = False

Then in the code used to open the message form, use:

DoCmd.OpenForm "MessageForm", , , , , acDialog
If forms!MessageForm!TextControlName = 1 Then
' Do the Proceed stuff
Else
' Do the Retry stuff
End If
DoCmd.Close acForm, "MessageForm"

All code processing will stop until one or the other button is
clicked.

There is only 1 text box .
It's used so that it's value of 1 or 2 (which is determined by which
command button is clicked) can be read by the code.
You don't want the code in the message form, you want that code in the
event that is used to open the message form, and which most likely
contains other data needed when the code continues, such as opening a
report using a where clause.
Not only that, but the message form can be adapted for other messages
and opened from other code where the button captions might then be
changed. The follow up code in the message form would not be
pertinent.
 
Could I thank everyone for the usual helpful responses? It would seem that a
satisfactory solution is indeed possible. Unfortunately, it is also appears
that I have got quite a lot of unnecessary code lurking in my 6Mb database!
It should be significantly slimmer in a week or two's time. I had better get
in a large stock of coffee.
 

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

Back
Top