Faking form as MsgBox

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

Guest

I've a database that has forms and controls colored to a specific pattern.
They are beautiful, but the MsgBox is where the pattern breaks and my Users
are complaining of lack of a consistent look.
This idea of a colorful interface with lots of mousemove actions, though I
didn't like, was thrust upon me.
Now, to overcome the problem, I want to fake my form as a MsgBox.
Can someone show me the light, please ?
 
I'll try to give an example on how to overcome you're "problem"

1. Create a form, nice looking one, with a text box in it,
set the properties:
Modal Property = Yes
PopUp Property = Yes
AutoCenter Property = Yes
NavigationButtons Property = No

2. Create a Function in a module
Function MyMsgBox (MyMessage As string)
' send the message to the form using the openArgs, change to the form name
you created
Docmd.OpenForm "FormName" , , , , , , MyMessage
End Function

3. On the form OnLoad event write
Me.TextBoxName = Me.OpenArgs

The text box name created in the form

=============
I hope that will provide you with a starting point
 
Thanks Ofer,

I've also got upto this point. I reproduce the exact code I'm using. But,
I'm clueless as to how to handle User Responses just like in regular VBA
MsgBox function.

--
Sreedhar

The Code:

Private Sub Form_Load()
On Error GoTo Err_Load

Dim strTitle As String
Dim strMessage As String
Dim strStyle As String

If Not IsNull(Me.OpenArgs) Then

strTitle = ParseWord(Me.OpenArgs, 1, ";")
strMessage = ParseWord(Me.OpenArgs, 2, ";")
strStyle = ParseWord(Me.OpenArgs, 3, ";")

Me!txtTitle = strTitle
Me!txtMessage = strMessage

Select Case strStyle
Case "1"
For Each ctl In Me.Controls
If Left(ctl.Tag, 10) = "ButtonSet1" Then
If ctl.Tag = "ButtonSet1_cmd" Then ctl.Caption = "&Yes"
If ctl.Tag = "Buttonset1_lb" Then ctl.Caption = "&Yes"
End If
If Left(ctl.Tag, 10) = "ButtonSet2" Then
If ctl.Tag = "ButtonSet2_cmd" Then ctl.Caption = "&No"
If ctl.Tag = "Buttonset2_lb" Then ctl.Caption = "&No"
End If
If Left(ctl.Tag, 10) = "ButtonSet3" Then
ctl.Visible = False
End If
Next
Case "2"
For Each ctl In Me.Controls
If Left(ctl.Tag, 10) = "ButtonSet1" Then
If ctl.Tag = "ButtonSet1_cmd" Then ctl.Caption = "&Yes"
If ctl.Tag = "Buttonset1_lb" Then ctl.Caption = "&Yes"
End If
If Left(ctl.Tag, 10) = "ButtonSet2" Then
If ctl.Tag = "ButtonSet2_cmd" Then ctl.Caption = "&No"
If ctl.Tag = "Buttonset2_lb" Then ctl.Caption = "&No"
End If
If Left(ctl.Tag, 10) = "ButtonSet3" Then
If ctl.Tag = "ButtonSet3_cmd" Then ctl.Caption = "&Cancel"
If ctl.Tag = "Buttonset3_lb" Then ctl.Caption = "&Cancel"
End If
Next
Case "3"
For Each ctl In Me.Controls
If Left(ctl.Tag, 10) = "ButtonSet1" Then
If ctl.Tag = "ButtonSet1_cmd" Then ctl.Caption = "&OK"
If ctl.Tag = "Buttonset1_lb" Then ctl.Caption = "&OK"
End If
If Left(ctl.Tag, 10) = "ButtonSet2" Then
ctl.Visible = False
End If
If Left(ctl.Tag, 10) = "ButtonSet3" Then
ctl.Visible = False
End If
Next
Case "4"
For Each ctl In Me.Controls
If Left(ctl.Tag, 10) = "ButtonSet1" Then
If ctl.Tag = "ButtonSet1_cmd" Then ctl.Caption = "&OK"
If ctl.Tag = "Buttonset1_lb" Then ctl.Caption = "&OK"
End If
If Left(ctl.Tag, 10) = "ButtonSet2" Then
If ctl.Tag = "ButtonSet2_cmd" Then ctl.Caption = "&Cancel"
If ctl.Tag = "Buttonset2_lb" Then ctl.Caption = "&Cancel"
End If
If Left(ctl.Tag, 10) = "ButtonSet3" Then
ctl.Visible = False
End If
Next
End Select

End If

Exit_Load:
Exit Sub

Err_Load:
ErrorLog "Form_Load", Err, Error
Resume Exit_Load

End Sub
 
Sreedhar said:
Thanks Ofer,

I've also got upto this point. I reproduce the exact code I'm using.
But, I'm clueless as to how to handle User Responses just like in
regular VBA MsgBox function.

Have the buttons set a value in a hidden control on the "message box form"
and then just hide the form rather than closing it. Your calling code can
read the value from the hidden control and then close it.
 
I can't tell if that was sarcastic or not? If it was, it must have
been based on my "magic of Google" statement. I did not mean to be
condescending, it is just that I use google at least 10 times a day to
solve problems. Those links were buried on page 3 or 4 of my search.

If it wasn't sarcastic, you are welcome.


Chris
 
No No No. I was really meaning it was magic. Nothing else intended. Sorry if
my oneliner hurt you. I was too excited to receive the sample from your first
link that I had to rush to test the code. That's why I kept my post short
with a sincere "thanks" as an attachment :-)
 
Back
Top