Method to Maximize Form Use

  • Thread starter Thread starter Ken Hudson
  • Start date Start date
K

Ken Hudson

I have a table to track projects. In that table I have a field used to
signify whether the project is complete or in process.
I have a form that is supported by a query. The query uses the project
complete field to pull only those projects that are in process. I also want
to use a query and form to pull completed projects.
I can accomplish this goal by creating two queries and two forms, one for in
process and one for complete.
I am using a form swithboard to open the projects form. Is there a way to
create two switchboard buttons (one for in process and one for completed
projects) that would somehow "pass" a "1" for completed or a "2" for in
process to the query before it runs so I can use just one query and one form?
 
You could include in the event or macro called by switchboard button to open
a form, not visible, with unbound text box and set value. Then include that
form/textbox as criteria in the query.
 
Thanks for the reposne Karl.
I am struggling to conceptualize this process.
I want one event in which the the query (qryPopForm) that supports the form
(frmEditProjects) gets a "C" for complete. And anther action in which that
query gets an "I" for incomplete. If I use the form (frmEditProjects) in a
macro, the query will run first to populate the form. I can't figure out how
to set up the form you mention and get the query to use that unbound data
when it executes.
Sorry, but I am not able understand the technical way to do this.
 
Edit query qryPopForm to include criteria from form with unbound textbox.
Name the form frmTempCriteria and unbound textbox named TempCriteria. the
criteria for your qryPopForm will be --
[Forms]![frmTempCriteria]![TempCriteria]

Switchboard calls macro Complete.
First macro action - Open form with unbound textbox.
Second macro action - Set value form with unbound textbox to "C".
Third macro action - Open form frmEditProjects.

Switchboard calls macro Incomplete.
First macro action - Open form with unbound textbox.
Second macro action - Set value form with unbound textbox to "I".
Third macro action - Open form frmEditProjects.
 
When you say switchboard, do you mean the access built in switchboard, or
the general term of your startup form?

The problems using the switchboard is, that a developer after have done just
about anything in access will likely toss it out and build their own form
with some buttons on it.

In other words the switchboard is kind of a set of
training wheels to get you going, but the instant you want to do something
differently, you should just simply build your own form with buttons on
them.

The simple way to do this is simply to base the form on a table or the
query, but have no criteria in that query, and then pass the form what is
called a where clause. The where clause is designed specifically to solve
your problem so that you don't need to have a new query or data source for
form when you want a open a form with different criteria.

The code behind the two buttons would look as follows

docmd.OpenForm "name of form",,,"Completed = True"

and, for the other buttion code you would use

docmd.OpenForm "name of form",,,"Completed = False"

I have not used a switchboard for a number of years, and I don't believe it
allows you to add parameters like where clause. If the swtich board does
then you can likey continue using the switchboard in place of building your
own startup form....
 
I have developed my own switchboard. I just didn't know how to "pass" that
parameter in code.
Your advice worked perfectly.
Thanks!
 
Hi Karl,
Thanks for the clarification. Before I had a chance to work your method, I
got another response which seemed a little simpler to me and I used that one.
But thanks again for your input!

--
Ken Hudson


KARL DEWEY said:
Edit query qryPopForm to include criteria from form with unbound textbox.
Name the form frmTempCriteria and unbound textbox named TempCriteria. the
criteria for your qryPopForm will be --
[Forms]![frmTempCriteria]![TempCriteria]

Switchboard calls macro Complete.
First macro action - Open form with unbound textbox.
Second macro action - Set value form with unbound textbox to "C".
Third macro action - Open form frmEditProjects.

Switchboard calls macro Incomplete.
First macro action - Open form with unbound textbox.
Second macro action - Set value form with unbound textbox to "I".
Third macro action - Open form frmEditProjects.


Ken Hudson said:
Thanks for the reposne Karl.
I am struggling to conceptualize this process.
I want one event in which the the query (qryPopForm) that supports the form
(frmEditProjects) gets a "C" for complete. And anther action in which that
query gets an "I" for incomplete. If I use the form (frmEditProjects) in a
macro, the query will run first to populate the form. I can't figure out how
to set up the form you mention and get the query to use that unbound data
when it executes.
Sorry, but I am not able understand the technical way to do this.
 
Back
Top