V
VWP1
How does a person create a message box which is a popup form instead of the
standard boring gray rectangle?
standard boring gray rectangle?
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.
(...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."
In order to do what you want, you will have to expand upon the very basic1) This five lines of code is the only code in this popup form.
Personally, I would use a label only to display text... there's no need for2) The popup form opens.
3) The label inherits the quote, but the corresponding textbox is empty.
The lines of code you have in the form do nothing to fill in the textbox,4) The Error is not specified; the textbox is blank/null.
Now we have a situation where you want to see more than one piece ofI would like to see the Error #, and teh text that Windows includes on the
ugly gray rectangle.
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)
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)
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?