Hey all,
I have an interesting problem. I had posted earlier about making "Message Boxes" non-centered. It's for an app that's on dual monitors, and well, a message box split between two monitors sucks. I got some great responses about creating a modal form with borderstyle set to dialog. I was cruising along well until...
This is a fairly large app with tons of message boxes. Since I will be using my form "frmOkYesNo" for multiple things, I thought it would be simple to add class functionality via property let and property get functions and call it as such:
[tt]dim MyDialog as New form_frmOkYesNo
MyDialog.modal=true
MyDialog.visible=true
select case MyDialog.reply '
...
end case[/tt]
The problem is that even if I set the design-time properties (BorderStyle as Dialog, popup, and modal), the form doesn't stop program execution and of course, it closes once the calling procedure destroys the object.
Short of doing this: (Not pretty but it DOES work)
[tt]do while isnull(MyDialog.reply)
DoEvents
loop[/tt]
I can't figure out why it doesn't work as expected. I don't want to create a different form for each type of dialog that I want, nor do I want to pass arguments via form.openargs. I realize that docmd.openform MyForm,,,,ACDialog (forgive me if there are too many commas -lol) solves my Dialog problem, but it leaves me with a much less flexible solution.
Any thoughts? Following is the code I'm using in the form. It's not entirely complete, but unless I can get this little part working it's moot anyway.
Thanks!
Jeff
[tt]'Form frmOkYesNo
Option Compare Database
Private m_YesCaption As String
Private m_NoCaption As String
Private m_OkCaption As String
Private m_BodyText As String
Private m_FormCaption As String
Private m_Reply As Integer
Private m_FormType As Integer
Public Enum FormTypeConstants
OKDialog = 1
YesNoDialog = 2
ErrorDialog = 3
End Enum
Public Property Let YesCaption(NewValue As String)
m_YesCaption = NewValue
End Property
Public Property Let NoCaption(NewValue As String)
m_NoCaption = NewValue
End Property
Public Property Let OkCaption(NewValue As String)
m_OkCaption = NewValue
End Property
Public Property Let FormCaption(NewValue As String)
m_FormCaption = NewValue
End Property
Public Property Let BodyText(NewValue As String)
m_BodyText = NewValue
End Property
Public Property Get Reply()
Reply = m_Reply
End Property
Public Property Let FormType(NewValue As FormTypeConstants)
m_FormType = NewValue
End Property
Public Sub SetUpDialog()
If Not IsNull(m_YesCaption) Then btnYes.Caption = m_YesCaption
If Not IsNull(m_NoCaption) Then btnNo.Caption = m_NoCaption
If Not IsNull(m_OkCaption) Then btnOK.Caption = m_OkCaption
If Not IsNull(m_FormCaption) Then Me.Caption = m_FormCaption
If Not IsNull(m_BodyText) Then lblText.Caption = m_BodyText
' Select Case m_FormType
'
' Case OKDialog
' btnNo.Visible = False
' btnYes.Visible = False
' btnOK.Visible = True
'
' Case YesNoDialog
' btnNo.Visible = True
' btnYes.Visible = True
' btnOK.Visible = False
'
' Case ErrorDialog
' btnNo.Visible = False
' btnYes.Visible = False
' btnOK.Visible = OK
' Me.FormCaption = "ERROR!"
' End Select
End Sub
Private Sub btnNo_Click()
m_Reply = vbNo
End Sub
Private Sub btnOk_Click()
m_Reply = vbOK
End Sub
Private Sub btnYes_Click()
m_Reply = vbYes
End Sub[/tt]
I have an interesting problem. I had posted earlier about making "Message Boxes" non-centered. It's for an app that's on dual monitors, and well, a message box split between two monitors sucks. I got some great responses about creating a modal form with borderstyle set to dialog. I was cruising along well until...
This is a fairly large app with tons of message boxes. Since I will be using my form "frmOkYesNo" for multiple things, I thought it would be simple to add class functionality via property let and property get functions and call it as such:
[tt]dim MyDialog as New form_frmOkYesNo
MyDialog.modal=true
MyDialog.visible=true
select case MyDialog.reply '
...
end case[/tt]
The problem is that even if I set the design-time properties (BorderStyle as Dialog, popup, and modal), the form doesn't stop program execution and of course, it closes once the calling procedure destroys the object.
Short of doing this: (Not pretty but it DOES work)
[tt]do while isnull(MyDialog.reply)
DoEvents
loop[/tt]
I can't figure out why it doesn't work as expected. I don't want to create a different form for each type of dialog that I want, nor do I want to pass arguments via form.openargs. I realize that docmd.openform MyForm,,,,ACDialog (forgive me if there are too many commas -lol) solves my Dialog problem, but it leaves me with a much less flexible solution.
Any thoughts? Following is the code I'm using in the form. It's not entirely complete, but unless I can get this little part working it's moot anyway.
Thanks!
Jeff
[tt]'Form frmOkYesNo
Option Compare Database
Private m_YesCaption As String
Private m_NoCaption As String
Private m_OkCaption As String
Private m_BodyText As String
Private m_FormCaption As String
Private m_Reply As Integer
Private m_FormType As Integer
Public Enum FormTypeConstants
OKDialog = 1
YesNoDialog = 2
ErrorDialog = 3
End Enum
Public Property Let YesCaption(NewValue As String)
m_YesCaption = NewValue
End Property
Public Property Let NoCaption(NewValue As String)
m_NoCaption = NewValue
End Property
Public Property Let OkCaption(NewValue As String)
m_OkCaption = NewValue
End Property
Public Property Let FormCaption(NewValue As String)
m_FormCaption = NewValue
End Property
Public Property Let BodyText(NewValue As String)
m_BodyText = NewValue
End Property
Public Property Get Reply()
Reply = m_Reply
End Property
Public Property Let FormType(NewValue As FormTypeConstants)
m_FormType = NewValue
End Property
Public Sub SetUpDialog()
If Not IsNull(m_YesCaption) Then btnYes.Caption = m_YesCaption
If Not IsNull(m_NoCaption) Then btnNo.Caption = m_NoCaption
If Not IsNull(m_OkCaption) Then btnOK.Caption = m_OkCaption
If Not IsNull(m_FormCaption) Then Me.Caption = m_FormCaption
If Not IsNull(m_BodyText) Then lblText.Caption = m_BodyText
' Select Case m_FormType
'
' Case OKDialog
' btnNo.Visible = False
' btnYes.Visible = False
' btnOK.Visible = True
'
' Case YesNoDialog
' btnNo.Visible = True
' btnYes.Visible = True
' btnOK.Visible = False
'
' Case ErrorDialog
' btnNo.Visible = False
' btnYes.Visible = False
' btnOK.Visible = OK
' Me.FormCaption = "ERROR!"
' End Select
End Sub
Private Sub btnNo_Click()
m_Reply = vbNo
End Sub
Private Sub btnOk_Click()
m_Reply = vbOK
End Sub
Private Sub btnYes_Click()
m_Reply = vbYes
End Sub[/tt]