Customizing a Popup Form as a Message Box

V

VWP1

How does a person create a message box which is a popup form instead of the
standard boring gray rectangle?
 
B

Barry A&P

Im reasonably new to this but here is the approach i would start on

create a form to look however you want with a unbound textbox..
set its Modal property yes (has to be closed to continue)

then in your code where you had a message box
DoCmd.OpenForm "messageform"
Forms.messageform.messagetextbox = "here is your text"

hope this helps
Barry
 
J

Jack Leach

Barry's idea would work, but here's another one you can work with...

Rather than having to set the Modal property to Yes, you can open the form
in acDialog mode... this suspends further code from running in the module
that called it. Ex:

somecode
somecode
DoCmd.OpenForm "FormName", , , , , acDialog
thiscode
willnotrun
untiltheform
isclosed

If you like, rather than referring to the message you want to display
through the Forms collection as Barry provided, you can also pass this
information as an open arg and handle it in the open even of the popup form...

DoCmd.OpenForm "FormName", , , , , acDialog, "This Message"

Then, in the open event, you read the open args and apply them...

Private Sub Form_Open(Cancel As Integer)
If Len(Nz(Me.OpenArgs, "")) <> 0 Then
Me.MessageLabel.Caption = Me.OpenArgs
End If
End Sub

Using this openargs approach is nice because you can pass a multitude of
information seperated by a delimiter (presumably a semicolon or pipe |
character) to really get some customization. The number of buttons you want,
what you want them to say (what you want them to do when clicked), icons or
images to display, even colors and sizes, user input text boxes that you can
show or hide... the list is really limitless, you just need a standard for
giving and reading the open arg value list.


Barry's way is one way to do it, and there's nothing wrong with that, but I
thought I'd throw out another option for consideration.

One last thing, though probably not for the beginner, would be to write a
class to handle it (there may even be a few out there already... probably
are). With a class module to do this you could get all of that customization
and make it quite programmer friendly (after setting up the class, of course)
:)

hth


--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
V

VWP1

In the form: f_fn_incm_nw (aptly referred to as form1), there is a label
(named: next) which has the following event procedure:

When typing the paycheck amount, the date, and the federal and state tax
deductions, etc on form1, I click the label: NEXT to link to form2 of the
paystub logging process, which is vacation, sick time, etc. The ID of the
form1 is the same as the ID for the form2, seeing that the paycheck is the
same. However, I mispelled the DocName as "form 2" instead of "form2" to
invoke the message popup form.

Naturally, each of the following are the same object _event and so I tried
each, individually.

'The ORIGINAL VBA of form1 (data entry mode):
__________________________

Private Sub next_Click()
On Error GoTo Err_next_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "form 2" 'mispelled

stLinkCriteria = "[paycheckID]=" & Me![paycheckID]
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_next_Click:
Exit Sub

Err_next_Click:
MsgBox Err.Description
Resume Exit_next_Click

End Sub
________________________

'My Interpretation of Barry's help (which works well, but...):

Private Sub next_Click()
On Error GoTo Err_next_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "form 2"

stLinkCriteria = "[paycheckID]=" & Me![paycheckID]
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_next_Click:
Exit Sub

Err_next_Click:
DoCmd.OpenForm "f_msg_pop"
Forms.f_msg_pop.messagetextbox = "The VBA code needs adjustment."
Resume Exit_next_Click

End Sub
(...but the quoted text doesn't provide me with the problem, such as
the ID field is mispelled, or that the form cannot be found..the argument)

______________________

Private Sub next_Click()
On Error GoTo Err_next_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "form 2"

stLinkCriteria = "[paycheckID]=" & Me![paycheckID]
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_next_Click:
Exit Sub

Err_next_Click:
Err_next_Click:
DoCmd.OpenForm "f_msg_pop", , , , , acDialog, "This is the label for
this unbound textbox."

Resume Exit_next_Click

End Sub

______________________

According to my interpretation of Jack's suggestion, the following code
went into the VBA for the popup form named: f_msg_pop

Option Compare Database

Private Sub Form_Open(Cancel As Integer)
If Len(Nz(Me.OpenArgs, "")) <> 0 Then
Me.MessageLabel.Caption = Me.OpenArgs
End If
End Sub

1) This five lines of code is the only code in this popup form.
2) The popup form opens.
3) The label inherits the quote, but the corresponding textbox is empty.
4) The Error is not specified; the textbox is blank/null.

I would like to see the Error #, and teh text that Windows includes on the
ugly gray rectangle.
 
J

Jack Leach

(...but the quoted text doesn't provide me with the problem, such as
the ID field is mispelled, or that the form cannot be found..the argument) ....
1) This five lines of code is the only code in this popup form.
2) The popup form opens.
3) The label inherits the quote, but the corresponding textbox is empty.
4) The Error is not specified; the textbox is blank/null.

I would like to see the Error #, and teh text that Windows includes on the
ugly gray rectangle.


Well, you need to give this information to the form if you want it to
display it... it doesn't read your mind. It will be up to you to pass that
information to the form or to somehow coordinate it so the form displays the
information you want.



Consider this...
(...but the quoted text doesn't provide me with the problem, such as
the ID field is mispelled, or that the form cannot be found..the argument)
Forms.f_msg_pop.messagetextbox = "The VBA code needs adjustment."

Forms.f_msg_pop.messagetextbox = _
"The VBA code needs adjustment, " & _
"Please correct the value passed to the argument: " & _
Err.Number & " " & Err.Description


This is one way to get more information there.


Let me elaborate a bit more on my previous suggestion...
1) This five lines of code is the only code in this popup form.
In order to do what you want, you will have to expand upon the very basic
example I provided. As your needs grow, so will your code.
2) The popup form opens.
3) The label inherits the quote, but the corresponding textbox is empty.
Personally, I would use a label only to display text... there's no need for
a textbox, I don't think, unless you want the user to type something in.
Sure, you can disable the text box and format it so it doesn't look like a
textbox, but you can easily use a label instead.
4) The Error is not specified; the textbox is blank/null.
The lines of code you have in the form do nothing to fill in the textbox,
and no reference of the error number or description has been given to the
form, so you can't expect it to display anything. Per the code in the open
event, the only thing it will display is what is passed as the open argument.
If you want the form to accept more detailed information, you have to
provide that information.
I would like to see the Error #, and teh text that Windows includes on the
ugly gray rectangle.
Now we have a situation where you want to see more than one piece of
information in your custom messagebox form. Recall that earlier I mentioned
that you can pass a multitude of information, if you have a system for
identifying the information being passed.

You want to pass
a) error number
b) error description, and
c) a custom message

No problem, but we have to tell vba to do this. The way to pass this
multiple information to the form is through the open arg. We will build a
string that contains all of the values, and use a delimiter of "|" so that we
can decipher the values on the popup side of the form. The syntax of our
string might look like this:

<errnum>|<errdesc>|<custommsg>

So, if you have error number 9, Subscript out of range, and want to pass a
custom message of "please check the subscript range", we would pass an open
arg like so...

"9|Subscript out of range|please check the subscript range"

In VBA, you will enter the first two portions of the line
programmatically... through the err.* properties, so the line will be
programmed as so:

Err.Number & "|" & Err.Description & "|" & "Please check the subscript range"



So now we have this string as an open arg that actually contains three
different values...

On the popup side, we want to break those values down and apply them
accordingly. Lets pretend we have three labels that we are going to set...
lblErrNum, lblErrDesc, and lblMessage.

In the open event, we need to parse the open arg into seperate values so
that we can apply each one to it's corresponding label. We will do this by
splitting the string into an array, so the elements of the array will each
contain a value that we need. They will be ordered in the same order that
they were in the string.

So now that we have a little more to deal with, let's go back to the open
event and pretend that we're dealing with this string above being passed....


Option Compare Database
Option Explicit

Private Sub Form_Open(Cancel As Integer)

Dim vArr As Variant 'this will be our array to hold each value

If Len(Nz(Me.OpenArgs, "")) = 0 Then
'if no open args was passed lets not open the form
Cancel = True
Exit Sub
End If

'now split the open args string into the array
vArr = Split(Me.OpenArgs, "|")

'just for demonstration, lets debug.print the values
Debug.Print vArr(0) 'err number
Debug.Print vArr(1) 'err description
Debug.Print vArr(2) 'custom message

'apply the values to the labels
Me.lblErrNum.Caption = vArr(0)
Me.lblErrDesc.Caption = vArr(1)
Me.lblMessage.Caption = vArr(2)

'now your form should have these three peices of information.
'add appropriate error handling

End Sub







Hopefully this gives some idea of what may be required in order to achieve
the results you are looking for. Unfortunately, when it comes to
programming, the more felixibility the programmer wants out of something, the
more thought needs to go into it. We have to tell our program EVERYTHING...
it does not assume. This may be a little more than you had in mind... you
might be better off dealing with the regular old message box for the time
being, until you become a bit more familiar with how VBA on the whole works.

One last piece of advice... include Option Explicit at the top of EVERY
module. This is very important.

Good luck


--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)



VWP1 said:
In the form: f_fn_incm_nw (aptly referred to as form1), there is a label
(named: next) which has the following event procedure:

When typing the paycheck amount, the date, and the federal and state tax
deductions, etc on form1, I click the label: NEXT to link to form2 of the
paystub logging process, which is vacation, sick time, etc. The ID of the
form1 is the same as the ID for the form2, seeing that the paycheck is the
same. However, I mispelled the DocName as "form 2" instead of "form2" to
invoke the message popup form.

Naturally, each of the following are the same object _event and so I tried
each, individually.

'The ORIGINAL VBA of form1 (data entry mode):
__________________________

Private Sub next_Click()
On Error GoTo Err_next_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "form 2" 'mispelled

stLinkCriteria = "[paycheckID]=" & Me![paycheckID]
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_next_Click:
Exit Sub

Err_next_Click:
MsgBox Err.Description
Resume Exit_next_Click

End Sub
________________________

'My Interpretation of Barry's help (which works well, but...):

Private Sub next_Click()
On Error GoTo Err_next_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "form 2"

stLinkCriteria = "[paycheckID]=" & Me![paycheckID]
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_next_Click:
Exit Sub

Err_next_Click:
DoCmd.OpenForm "f_msg_pop"
Forms.f_msg_pop.messagetextbox = "The VBA code needs adjustment."
Resume Exit_next_Click

End Sub
(...but the quoted text doesn't provide me with the problem, such as
the ID field is mispelled, or that the form cannot be found..the argument)

______________________

Private Sub next_Click()
On Error GoTo Err_next_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "form 2"

stLinkCriteria = "[paycheckID]=" & Me![paycheckID]
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_next_Click:
Exit Sub

Err_next_Click:
Err_next_Click:
DoCmd.OpenForm "f_msg_pop", , , , , acDialog, "This is the label for
this unbound textbox."

Resume Exit_next_Click

End Sub

______________________

According to my interpretation of Jack's suggestion, the following code
went into the VBA for the popup form named: f_msg_pop

Option Compare Database

Private Sub Form_Open(Cancel As Integer)
If Len(Nz(Me.OpenArgs, "")) <> 0 Then
Me.MessageLabel.Caption = Me.OpenArgs
End If
End Sub

1) This five lines of code is the only code in this popup form.
2) The popup form opens.
3) The label inherits the quote, but the corresponding textbox is empty.
4) The Error is not specified; the textbox is blank/null.

I would like to see the Error #, and teh text that Windows includes on the
ugly gray rectangle.

Jack Leach said:
Barry's idea would work, but here's another one you can work with...

Rather than having to set the Modal property to Yes, you can open the form
in acDialog mode... this suspends further code from running in the module
that called it. Ex:

somecode
somecode
DoCmd.OpenForm "FormName", , , , , acDialog
thiscode
willnotrun
untiltheform
isclosed

If you like, rather than referring to the message you want to display
through the Forms collection as Barry provided, you can also pass this
information as an open arg and handle it in the open even of the popup form...

DoCmd.OpenForm "FormName", , , , , acDialog, "This Message"

Then, in the open event, you read the open args and apply them...

Private Sub Form_Open(Cancel As Integer)
If Len(Nz(Me.OpenArgs, "")) <> 0 Then
Me.MessageLabel.Caption = Me.OpenArgs
End If
End Sub

Using this openargs approach is nice because you can pass a multitude of
information seperated by a delimiter (presumably a semicolon or pipe |
character) to really get some customization. The number of buttons you want,
what you want them to say (what you want them to do when clicked), icons or
images to display, even colors and sizes, user input text boxes that you can
show or hide... the list is really limitless, you just need a standard for
giving and reading the open arg value list.


Barry's way is one way to do it, and there's nothing wrong with that, but I
thought I'd throw out another option for consideration.

One last thing, though probably not for the beginner, would be to write a
class to handle it (there may even be a few out there already... probably
are). With a class module to do this you could get all of that customization
and make it quite programmer friendly (after setting up the class, of course)
:)

hth


--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
J

Jack Leach

I also feel obligated to note that what you ultimately seem to be trying to
accomplish goes quite a bit further than just creating a custom message box.
What you are attempting to do is create custom handling system for your
errors. This is entirely seperate monster.

To gather some more ideas on this, do some google searches for Global Error
Handlers. Know that this is not impossible, but also note that this concept
requires a lot of up-front planning to handle every possibility that might
arise throughout your application.

With Global Error Handling, or with a Custom Message Box Form, the idea is
to make everything as "global" as possible. That is... these will be called
from multiple different places in your code as your project evolves, and
these type of top level functionalities need to be designed in order to
handle a multitude of different scenarios in which they will be used.

Often, designing these global functionalities is one of the more difficult
tasks that programmers face, because of the need to make them so versitile.
There's much preplanning that needs to go into them, and when you have it
done and start using them elsewhere in your code, the last though you want to
do is going chaning them (and whatever related code you may have) down the
line.

Myself, I've taken on a few of these types of projects, and have literally
put my normal development completely on hold for days or sometimes weeks
until everything was proofed.

just some food for thought...


--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



VWP1 said:
In the form: f_fn_incm_nw (aptly referred to as form1), there is a label
(named: next) which has the following event procedure:

When typing the paycheck amount, the date, and the federal and state tax
deductions, etc on form1, I click the label: NEXT to link to form2 of the
paystub logging process, which is vacation, sick time, etc. The ID of the
form1 is the same as the ID for the form2, seeing that the paycheck is the
same. However, I mispelled the DocName as "form 2" instead of "form2" to
invoke the message popup form.

Naturally, each of the following are the same object _event and so I tried
each, individually.

'The ORIGINAL VBA of form1 (data entry mode):
__________________________

Private Sub next_Click()
On Error GoTo Err_next_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "form 2" 'mispelled

stLinkCriteria = "[paycheckID]=" & Me![paycheckID]
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_next_Click:
Exit Sub

Err_next_Click:
MsgBox Err.Description
Resume Exit_next_Click

End Sub
________________________

'My Interpretation of Barry's help (which works well, but...):

Private Sub next_Click()
On Error GoTo Err_next_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "form 2"

stLinkCriteria = "[paycheckID]=" & Me![paycheckID]
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_next_Click:
Exit Sub

Err_next_Click:
DoCmd.OpenForm "f_msg_pop"
Forms.f_msg_pop.messagetextbox = "The VBA code needs adjustment."
Resume Exit_next_Click

End Sub
(...but the quoted text doesn't provide me with the problem, such as
the ID field is mispelled, or that the form cannot be found..the argument)

______________________

Private Sub next_Click()
On Error GoTo Err_next_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "form 2"

stLinkCriteria = "[paycheckID]=" & Me![paycheckID]
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_next_Click:
Exit Sub

Err_next_Click:
Err_next_Click:
DoCmd.OpenForm "f_msg_pop", , , , , acDialog, "This is the label for
this unbound textbox."

Resume Exit_next_Click

End Sub

______________________

According to my interpretation of Jack's suggestion, the following code
went into the VBA for the popup form named: f_msg_pop

Option Compare Database

Private Sub Form_Open(Cancel As Integer)
If Len(Nz(Me.OpenArgs, "")) <> 0 Then
Me.MessageLabel.Caption = Me.OpenArgs
End If
End Sub

1) This five lines of code is the only code in this popup form.
2) The popup form opens.
3) The label inherits the quote, but the corresponding textbox is empty.
4) The Error is not specified; the textbox is blank/null.

I would like to see the Error #, and teh text that Windows includes on the
ugly gray rectangle.

Jack Leach said:
Barry's idea would work, but here's another one you can work with...

Rather than having to set the Modal property to Yes, you can open the form
in acDialog mode... this suspends further code from running in the module
that called it. Ex:

somecode
somecode
DoCmd.OpenForm "FormName", , , , , acDialog
thiscode
willnotrun
untiltheform
isclosed

If you like, rather than referring to the message you want to display
through the Forms collection as Barry provided, you can also pass this
information as an open arg and handle it in the open even of the popup form...

DoCmd.OpenForm "FormName", , , , , acDialog, "This Message"

Then, in the open event, you read the open args and apply them...

Private Sub Form_Open(Cancel As Integer)
If Len(Nz(Me.OpenArgs, "")) <> 0 Then
Me.MessageLabel.Caption = Me.OpenArgs
End If
End Sub

Using this openargs approach is nice because you can pass a multitude of
information seperated by a delimiter (presumably a semicolon or pipe |
character) to really get some customization. The number of buttons you want,
what you want them to say (what you want them to do when clicked), icons or
images to display, even colors and sizes, user input text boxes that you can
show or hide... the list is really limitless, you just need a standard for
giving and reading the open arg value list.


Barry's way is one way to do it, and there's nothing wrong with that, but I
thought I'd throw out another option for consideration.

One last thing, though probably not for the beginner, would be to write a
class to handle it (there may even be a few out there already... probably
are). With a class module to do this you could get all of that customization
and make it quite programmer friendly (after setting up the class, of course)
:)

hth


--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
V

VWP1

On that morsel of food for thought, Perhaps I can create a popup form for
common instances, such as 1. clicking the next button before filling in all
the textboxes or selecting a radio button (whereby teh next button would take
the user to the next form or 2. Entering data which is compared against a
table, and "Not in List" or something along these lines.

Jack Leach said:
I also feel obligated to note that what you ultimately seem to be trying to
accomplish goes quite a bit further than just creating a custom message box.
What you are attempting to do is create custom handling system for your
errors. This is entirely seperate monster.

To gather some more ideas on this, do some google searches for Global Error
Handlers. Know that this is not impossible, but also note that this concept
requires a lot of up-front planning to handle every possibility that might
arise throughout your application.

With Global Error Handling, or with a Custom Message Box Form, the idea is
to make everything as "global" as possible. That is... these will be called
from multiple different places in your code as your project evolves, and
these type of top level functionalities need to be designed in order to
handle a multitude of different scenarios in which they will be used.

Often, designing these global functionalities is one of the more difficult
tasks that programmers face, because of the need to make them so versitile.
There's much preplanning that needs to go into them, and when you have it
done and start using them elsewhere in your code, the last though you want to
do is going chaning them (and whatever related code you may have) down the
line.

Myself, I've taken on a few of these types of projects, and have literally
put my normal development completely on hold for days or sometimes weeks
until everything was proofed.

just some food for thought...


--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



VWP1 said:
In the form: f_fn_incm_nw (aptly referred to as form1), there is a label
(named: next) which has the following event procedure:

When typing the paycheck amount, the date, and the federal and state tax
deductions, etc on form1, I click the label: NEXT to link to form2 of the
paystub logging process, which is vacation, sick time, etc. The ID of the
form1 is the same as the ID for the form2, seeing that the paycheck is the
same. However, I mispelled the DocName as "form 2" instead of "form2" to
invoke the message popup form.

Naturally, each of the following are the same object _event and so I tried
each, individually.

'The ORIGINAL VBA of form1 (data entry mode):
__________________________

Private Sub next_Click()
On Error GoTo Err_next_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "form 2" 'mispelled

stLinkCriteria = "[paycheckID]=" & Me![paycheckID]
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_next_Click:
Exit Sub

Err_next_Click:
MsgBox Err.Description
Resume Exit_next_Click

End Sub
________________________

'My Interpretation of Barry's help (which works well, but...):

Private Sub next_Click()
On Error GoTo Err_next_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "form 2"

stLinkCriteria = "[paycheckID]=" & Me![paycheckID]
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_next_Click:
Exit Sub

Err_next_Click:
DoCmd.OpenForm "f_msg_pop"
Forms.f_msg_pop.messagetextbox = "The VBA code needs adjustment."
Resume Exit_next_Click

End Sub
(...but the quoted text doesn't provide me with the problem, such as
the ID field is mispelled, or that the form cannot be found..the argument)

______________________

Private Sub next_Click()
On Error GoTo Err_next_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "form 2"

stLinkCriteria = "[paycheckID]=" & Me![paycheckID]
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_next_Click:
Exit Sub

Err_next_Click:
Err_next_Click:
DoCmd.OpenForm "f_msg_pop", , , , , acDialog, "This is the label for
this unbound textbox."

Resume Exit_next_Click

End Sub

______________________

According to my interpretation of Jack's suggestion, the following code
went into the VBA for the popup form named: f_msg_pop

Option Compare Database

Private Sub Form_Open(Cancel As Integer)
If Len(Nz(Me.OpenArgs, "")) <> 0 Then
Me.MessageLabel.Caption = Me.OpenArgs
End If
End Sub

1) This five lines of code is the only code in this popup form.
2) The popup form opens.
3) The label inherits the quote, but the corresponding textbox is empty.
4) The Error is not specified; the textbox is blank/null.

I would like to see the Error #, and teh text that Windows includes on the
ugly gray rectangle.

Jack Leach said:
Barry's idea would work, but here's another one you can work with...

Rather than having to set the Modal property to Yes, you can open the form
in acDialog mode... this suspends further code from running in the module
that called it. Ex:

somecode
somecode
DoCmd.OpenForm "FormName", , , , , acDialog
thiscode
willnotrun
untiltheform
isclosed

If you like, rather than referring to the message you want to display
through the Forms collection as Barry provided, you can also pass this
information as an open arg and handle it in the open even of the popup form...

DoCmd.OpenForm "FormName", , , , , acDialog, "This Message"

Then, in the open event, you read the open args and apply them...

Private Sub Form_Open(Cancel As Integer)
If Len(Nz(Me.OpenArgs, "")) <> 0 Then
Me.MessageLabel.Caption = Me.OpenArgs
End If
End Sub

Using this openargs approach is nice because you can pass a multitude of
information seperated by a delimiter (presumably a semicolon or pipe |
character) to really get some customization. The number of buttons you want,
what you want them to say (what you want them to do when clicked), icons or
images to display, even colors and sizes, user input text boxes that you can
show or hide... the list is really limitless, you just need a standard for
giving and reading the open arg value list.


Barry's way is one way to do it, and there's nothing wrong with that, but I
thought I'd throw out another option for consideration.

One last thing, though probably not for the beginner, would be to write a
class to handle it (there may even be a few out there already... probably
are). With a class module to do this you could get all of that customization
and make it quite programmer friendly (after setting up the class, of course)
:)

hth


--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



:

How does a person create a message box which is a popup form instead of the
standard boring gray rectangle?
 

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

Similar Threads


Top