Re: Opening additional (non-default) form instances

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I'm not completely clear about this, but I suggest you remove the parameter from the source query.

Instead, use the Load event of the from to filter it in the desired way, e.g.:
Private Sub Form_Load()
Dim strWhere As String
If CurrentProject.AllForms(Me.Name).IsLoaded Then
strWhere = "[SomeField] = " & Nz(Forms(Me.Name)!SomeCheckBox.Value, False)
Me.Filter = strWhere
Me.FilerOn = True
End If
End Sub

If this is another instance, it will look for the check box on one of the other instances, and filter itself accordingly.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Bob Bridges" <rhbridg.RemoveThisNode@xxxxxxxxxxxxx> wrote in message
news:5D784800-F445-4AEA-9B8E-6090DC2C4AEA@xxxxxxxxxxxxxxxx
So far I don't anticipate needing to track and control the individual
instances of the subforms; they're opened only as long as the user needs
them, and as soon as he's done with an instance he hits <Esc> and it
disappears. At least, that's what I did when there was only one of
everything, and I expect to do the same with the multiple instances. So for
now I think just putting each instance in the collection is all I need. But
I was sure I'll want to do better later, so I'll keep your hWnd suggestion in
mind for later, thanks.

The subform's records are populated from a query. Two of the three controls
in the header are filled in from controls in the active record of the parent
form. The third is a checkbox with nothing in the Control Source (in the
subform's Design mode) but a default value of False. This works fine for a
"default" open, if that's the term.

When I try to open the subform as a non-default New instance, before
anything else happens Access hands me an "Enter Parameter Value" prompt
asking for a value to put in the checkbox, ignoring that control's default
setting. When I first posted this question, the prompt accepted only <Esc>
or the Close button (the X at the upper right); anything else and it accused
me of having canceling the previous operation. But it's hours later and I've
since closed and reopened the database; now it requires <Enter> or the Ok
button, but otherwise is the same. My question, of course, is how to tell it
what value to use for the checkbox so it won't feel it has to prompt the user
for it.

Since it seemed to be ignoring the Default value, I tried putting =False in
the Control Source field. That got rid of the Parameter prompt, but I wasn't
allowed to manually check or uncheck the box thereafter.

I tried filling in a value during the Form_Open event, but it turns out this
prompt occurs BEFORE the event, so that was no help.

I imagine you already know what I need to do, but in case it's germane:
When the subform opens after the Parm prompt, the detail sections are
correctly filled in from the query. Earlier today the first two controls in
the header displayed as #Err, which I expected I could fill in by a couple of
statements in the code; but now they're filled in properly also. Go figure.
I can also open multiple copies of the subform, so it appears the only
problem is the Parameter prompt. How do I tell it what value to use for the
checkbox when I'm opening it as a non-default instance?

--- "Allen Browne" wrote:
Sounds like you have the New keyword working, and you are able to
manage the instances via your collection. My personal preference is to
use the hWnd of the form as its unique identifier. Details (and sample
database) in "Managing Multiple Instances of a Form" at
http://allenbrowne.com/ser-35.html.

If Access is asking you for a value when the form opens, there is a
name somewhere that it can't resolve. If the form is bound to a query,
the name could be there, either:
- a reference such [Forms].[Form1].[Text0], referring to something
that is not yet open.
- a name that doesn't come from a table;
- an alias that Access doesn't recognise;
- a problem with Name AutoCorrect.

If it's not there, perhaps it is in the Filter or OrderBy property of the
source query, or of the form.

(Hopefully this isn't a cyclic depencency, where the form depends on a query
that refers to the form.)

--- "Bob Bridges" <rhbridg.RemoveThisNode@xxxxxxxxxxxxx>:
> I think I'm about ready to learn how to open up a form more than > once -- > that is, how to use "instances" of forms, or to open "non-default"
> instances of them. Up 'til now, I've done it like this:
>
> DoCmd.OpenForm "clCoSub"
> DoCmd.Requery
>
> I read that I can open up a new form like this:
>
> Set x = New Form_clCoSub
> x.Visible=True
>
> ....some of the controls in the form aren't correctly populated with
> data when I use this method, but I'm sure I can populated them
> manually in the code. What I'm trying to figure out right now is
> why Access insists on asking me, at the time it's bringing up the
> form, to fill in the value of a checkbox on the form as it's getting
> ready to open it.
>
> Can anyone point me to a good technical article about non-default
> instances of forms so I can learn some of the things I've been only
> guessing at until now?

.



Relevant Pages

  • Re: UPDATE DATE FIELD IN QUERY
    ... In the Date Field of my Query I have entered the following into the Criteria ... I can open the query, and it does prompt start & end dates, but it opens the ... When I open the report it opens the same parameter window & not my form, ... End dates 6 times & it just kept bringing up the prompt. ...
    (microsoft.public.access.macros)
  • Re: Referring to a form in a query - Syntax
    ... the expression was producing a prompt when I included it as the ... criteria for a query or "Name?" ... when I pasted it on a report. ... When the report opens, it ...
    (microsoft.public.access.forms)
  • Re: macro query cancel causes error
    ... which in turn opens a query. ... The query has a built in prompt (text ... If you click on cancel when the ...
    (microsoft.public.access.macros)
  • Re: code to open list box from param query
    ... as a list box insted of the query. ... Set the ListBox Row Source Type property to Table/Query. ... When the form opens, it will prompt for the parameter. ...
    (comp.databases.ms-access)
  • Re: conditional formatting in form slows down calculations
    ... >> table to see all dates and a filtered query to see recent dates. ... If I set it to open with the record source the query, ... >> endless calculating when the form opens. ...
    (microsoft.public.access.forms)