Return value from 'personalised' message form (1 Viewer)

liddlem

Registered User.
Local time
Today, 09:40
Joined
May 16, 2003
Messages
339
Hi all
My users are dismissing messages that I display with a standard msgbox.

I therefore want to display a bespoke 'msgbox' that looks completely different to those displayed by the system.
That way - they will (hopefully) take more time to read the message - and answer the question properly.

I have created a form called Frm_Warning with the following objects.
Frm_Title
Frm_Message
Btn_One
Btn_Two

I have also created a global variable which is set, depending on which button was clicked by the user.

When a certain condition is met, the form is opened and the caption/values of each object are assigned, depending on what the trigger was.

However, If I open the Frm_Warning from any form, I must set its mode to ACDialog so that the code in the calling form waits for input from the Frm_Warning.

The problem is that I cannot open the form in ACDialog and then assign the values.
I also cannot open the form in ACEdit mode because then to the code on the calling form doesn't wait for the input from Frm_Warning.

How do i get around this?
 

MarkK

bit cruncher
Local time
Today, 01:40
Joined
Mar 17, 2004
Messages
8,179
You can 1) use the OpenArgs parameter of the DoCmd.OpenForm method call, or you can 2) assign a public value somewhere that the opening form can read.

1) In the first case you would do something like this in the calling code...
Code:
DoCmd.OpenForm "YourMessageForm", , , , , acDialog, "args"
...and then in the form that opens as a dialog you can read and use the OpenArgs property, like...
Code:
Private Sub Form_Open(Cancel As Integer)
[COLOR="Green"]   'proves that data was passed to the form[/COLOR]
   MsgBox Me.OpenArgs
End Sub

2) In this approach, set the value of some variable that stays in scope while the acDialog form opens, so maybe a TempVar, or a public variable on a hidden form...
Code:
TempVars("args") = "args"
DoCmd.OpenForm "YourMessageForm", , , , , acDialog
...and then as the form opens, we read the data previously placed in the TempVar...
Code:
private sub Form_Open(Cancel as Integer)
[COLOR="Green"]   'proves that we can read the TempVar value at "args"[/COLOR]
   msgbox TempVars("args")
end sub
For object types, open a hidden form with a public property of the type you want to pass to your acDialog form, assign the object to the hidden form's property, then when your acDialog form opens, read that property back from the hidden form.

hth
Mark
 

liddlem

Registered User.
Local time
Today, 09:40
Joined
May 16, 2003
Messages
339
Awesome - Thanks - I Got it working like a charm!
 

Users who are viewing this thread

Top Bottom