Modal Property Let

kirkm

Registered User.
Local time
Tomorrow, 00:38
Joined
Oct 30, 2008
Messages
1,257
Just wondering if a Form is opened modally, can Property Let be used anyhow?
Or is Open args the only way to send values to the Form ?
Thanks.
 
ust wondering if a Form is opened modally, can Property Let be used anyhow?
I am not sure the reason for the long diatribe, but the answer is YES, you can manipulate a form open Modal and even Modal/Dialog.
You CAN NOT manipulate a form open ACDIALOG, because code execution stops in the calling form. This is a simple experiment you can do on your own.
 
I don't quite get what's meant by 'manipulate the Form'. But yes UG the form is closed and I like to pass it a value as/before I open it. It seems Property Let cannot do that ? I was using acDialog (Isn't that the same as Open modal? I want the code block that calls the Form to wait, then continue when the Form is hidden).
as you open the form you call the function "fSetUp". Pass the information into to the custom properties, and then run the public function.
But doing this will not open the From as acDialog, will it ?
 
No in Access. Modal, Dialog, Pop Up, and opening in ACDIALOG are not the same. See dbGuys discussion
You may be confused because I think in MSFORMS modal stops code execution and I think that is the same in VB.NET. The terminology in Access is different for the same things.

But yes UG the form is closed and I like to pass it a value as/before I open it
I am assuming you are familar with doing this in other language like VB.NET, unfortunately in VBA you cannot do that. You cannot set a value/property prior to opening/instantiating a form. In VB.NET this is common. In VBA because of these limitations Access provides OpenArgs. The only purpose of OpenArgs is to pass value/s to a form open ACDIALOG. If the form is not open ACDIALOG then you could simply set properties of the form after opening it.

I want the code block that calls the Form to wait, then continue when the Form is hidden)
Unfortunately, the only way to do this is to open ACDIALOG. In that case the limitations I discuss prevail.
Your choices
1.) If it is a simple value, past the value in using OpenArgs. All values are strings so you may have to convert. But handle the openargs in the on load event.
2) If you want to pass multiple values you can separate them with a delimiter such as value1;value2;value3 and then split them apart using the split function. Again do this In the load event
3. If it is something complicated such as passing an object, then you are limited to hard-wiring the called form. You could set a global variable before opening the form. The called form could look for global variable/s on load and set the properties itself
 
If it is something complicated such as passing an object, then you are limited to hard-wiring the called form.

A few years ago, ChrisO (RIP) demonstrated using OpenArgs to pass a pointer to an object.
 
Many thanks MajP for that explanation and the link. I would have bet $$$ that modal and Dialog were the same.
Knowing the choices is a big help. Things falling into place nicely now. Cheers.
 
You can set "custom properties" as I've explained. The problem is, the Form Load Event happens before the properties are set so the Form load Event can't take advantage of them. There's a simple way round that problem, just call a public function.
@Uncle Gizmo
You can set custom properties but that is irrelevant to the discussion. Again the OP's whole discussion is about opening forms Dialog where code execution stops in the calling form. I know this because that is what the OP clearly states:
I want the code block that calls the Form to wait, then continue when the Form is hidden).

There is NO WAY to set custom or native properties of a form prior to opening/instantiating as I clearly stated.
You cannot set a value/property prior to opening/instantiating a form.

All you are demonstrating is opening/Instantiating a form in a non dialog mode then setting custom properties. Nothing really new to see here. This is clearly not what the OP is asking. The public function you suggest is only correcting a timing issue of the events. Again the "public function" is irrelevant because you cannot call it if opened DIALOG.

In Access there is no way to separate instantiation and opening a form and that is the problem. In other languages such as VB.NET you can instantiate the class, update properties, then open the form Modal. So you can do something like (pseudo code)
Code:
Dim frm as new formSomeForm
'the frm is now instantiated but not opened
'Now set the properties of the un-opened form
With frm
   .someProperty = "Red"
   Set .someOtherProperty = someObject
  ...
end with
'Now open the form modal
frm.openModal
 
Here is a demo using an MSFORM that shows what is being asked by the OP. The OP wants to
1. Set properties of a form before opening it
the form is closed and I like to pass it a value as/before I open it.
2. Open the form where code execution stops in the calling form and then starts again once the called form is closed.
I want the code block that calls the Form to wait, then continue when the Form is hidden).
As stated in some applications this is called "Modal", in access this is normally called "Dialog".

This cannot be done with an Access form, but it can be done in MSFORMS.

Code:
Private Sub cmdOpen_Click()
    Dim frm As MSFORM_1
    Dim clr As Long
    'Instantiate form without opening it
    Set frm = New MSFORM_1
    
    Select Case Me.FrameColor
      Case 1
        clr = vbRed
      Case 2
        clr = vbBlue
      Case 3
        clr = vbGreen
    End Select
    'set frm properties prior to instantiation
    frm.BackColor = clr
    frm.txtMessage = Me.txtMessage
    'Now open the form modal
    frm.Show
    'The following code does not execute because code execution is stopped in the previous line since form is modal
    MsgBox "The form was open modal(Access dialog); therefore code execution stopped prior to this line until the modal form is closed"
End Sub

In access there is no way to instantiate the form without opening it, here you can. With the MSFORM you can instantiate the form, set the properties, then open the form.
 

Attachments

@Galaxiom
I found the link.

Looks real interesting. I tried to get it to work, but needs to get converted to 64 bit, and I have no knowledge beyond typing PTRSafe. Have you used this? It looks so simple, I am surprised this is not commonly used.
 

Users who are viewing this thread

Back
Top Bottom