Set Form vs. DoCmd.OpenForm

K

Kevin

Hello all,

Access2k, Windows2k

I am stuck. I need the functionality of DoCmd.OpenForm but within the
flexibility of dim frm as New Form. Specifically, I need the ability to open
a form modally and the Set Form functionality. In pseudocode, what I need to
be able to do is:

Public Sub Test()

Dim frm as New Form_frmLogin
Set frm.UserProperty = myUserProperty
frm.Modal = True
frm.Visible = True

End Sub

I can't use DoCmd.OpenForm "frmLogin",,,,,acModal because I need to be able
to set some public properties of the form - which I can't do before the call
to DoCmd because the form doesn't exist yet, and I can't do after the DoCmd
because, being modal, subsequent lines of code won't execute until it is too
late. Is there a way to set properties of the form after opening it via the
DoCmd method?? ie...

DoCmd.OpenForm "frmLogin",,,,,acModal
Set Forms!frmLogin.UserProperty = myUserProperty

????? - The problem is that by opening the form as modal, the second line of
code never executes (at least not when I need it to). Any assistance would
be greatly appreciated.

Also, does anyone know if it is possible to reference .dll's built in VS.Net
from within Access2k? I keep getting errors, but haven't really explored it
yet. I'm porting my app to vb.net and would like to use my existing access
app as a test harness.

Thank you in advance...

Regards,

Kevin
 
K

Kevin

Kevin,

I have several forms which are opened and properties set
after the fact. If need be, set echo off (Docmd.Echo =
False). Make sure you set echo on after you complete your
form setup though because it will lockup your application.

Hope that helps!

Kevin
-----Original Message-----
Hello all,

Access2k, Windows2k

I am stuck. I need the functionality of DoCmd.OpenForm but within the
flexibility of dim frm as New Form. Specifically, I need the ability to open
a form modally and the Set Form functionality. In pseudocode, what I need to
be able to do is:

Public Sub Test()

Dim frm as New Form_frmLogin
Set frm.UserProperty = myUserProperty
frm.Modal = True
frm.Visible = True

End Sub

I can't use DoCmd.OpenForm "frmLogin",,,,,acModal because I need to be able
to set some public properties of the form - which I can't do before the call
to DoCmd because the form doesn't exist yet, and I can't do after the DoCmd
because, being modal, subsequent lines of code won't execute until it is too
late. Is there a way to set properties of the form after opening it via the
DoCmd method?? ie...

DoCmd.OpenForm "frmLogin",,,,,acModal
Set Forms!frmLogin.UserProperty = myUserProperty

????? - The problem is that by opening the form as modal, the second line of
code never executes (at least not when I need it to). Any assistance would
be greatly appreciated.

Also, does anyone know if it is possible to
reference .dll's built in VS.Net
 
T

TC

(snip)
I can't use DoCmd.OpenForm "frmLogin",,,,,acModal because I need to be able
to set some public properties of the form - which I can't do before the call
to DoCmd because the form doesn't exist yet, and I can't do after the DoCmd
because, being modal, subsequent lines of code won't execute until it is too
late.

Open the form *non* modal, set the props, then wait for the form to go away.

Untested:

' open form.
docmd.openform "blah"

' set props.
with forms("blah")
.prop1 = 1
.prop2 = 2
end with

' wait for form to go away.
dim s as string
on error resume next
while err.number = 0
doevents ' important!
s = forms("blah").name
wend
on error goto 0

HTH,
TC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top