Change Windowmode on Input Form

G

Garret

Hello,

Recently I created a form to take the place of the Window's
default input dialog. This form looks almost exactly like the default
one for User Interface sake. What I usually do is have that form open
up in acDialog mode through VBA code using

Docmd.openForm DoCmd.OpenForm "frmInputBox", acNormal, , , , acDialog

However, once that code runs, no other code can run until that
form closes or does focus (through making it's visible property to
false). In the past I had the problem of wanting to display different
messages on this Input Form, so I had a HiddenKey form - an invisible
form that holds data that acts as a middle man - that had a label that
was passed the message from the calling form, then when the InputForm
opened up (on its Form_Load event) it took the message from the
HiddenKey Form. That solved that problem.
Now I have a report that has its criteria set through input on
this Input Form. In one instance, I need to collect two values, a
month and a year, and use them to have the report filtered to open
records with a particular date field that contains that month and year.
I thought I could do this by changing the Input Form to have two
(rather than one) text boxes that appear (become visible) and the other
text box becomes invisible when the form opens when called from this
particular source.
The problem here lies in that Forms with a WindowMode of Dialog
cannot run code. I tried to open the form as Normal, reset the visible
properties, and then set it back to dialog, but I get an "Invalid use
of Null" error. Is there a way to open it as normal and then just set
it's windowmode instead of trying to open it again (since that seems to
be where the error is coming from)?
 
G

Garret

The only solutions I can think of if there is no way to change the
WindowMode, is to just create a second Input Form for this job
specifically, which seems like kind of a waste to me. Or I could pass
a value to the HiddenKey indicating that something is different, and on
the On_Load event of the Input Form, have it do all the visible
property changes there. Any help I would appreciate.
 
K

Ken Sheridan

Pass values to the dialogue form as its OpenArgs property. By passing
different values for different scenarios you can then execute different code
in the dialogue form's module depending on the value passed to the form.

I've posted a demo of how the OpenArgs property can be used more flexibly
than for passing a single value at:


http://community.netscape.com/n/pfx...yMessages&tsn=1&tid=24091&webtag=ws-msdevapps


The demo is based on some work I did to develop an original module produced
by my former colleague Stuart McCall in the old CompuServe MS Access forum.

Ken Sheridan
Stafford, England
 
G

Garret

Hi, thanks for responding. I checked out your database and have a
rough understand of what Args are now, and can kind of visualize how it
works. What would be the code to use to test if the Args are a
certain value?
 
K

Ken Sheridan

If you are simply passing one value as the OpenArgs property then:

If Not IsNull(Me.OpenArgs) Then
Select Case Me.OpenArgs
Case "foo"
<do something>
Case "bar"
<do something else>
End Select
End If

If you are using one of my methods to pass named or numbered multiple
arguments it would depend on which method you are using.
 

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