Two Command Buttons Open a Signle Form

S

snichols

Hi. I have a Switchboard with two buttons that should open the same form
(frmEditProjectStatus) as follows:

Button 1- Used to add a new record. No problems with this one.
Button 2- Used to make a combo box visible. When a user selects his/her name
from the combo box a list of that user's projects is shown. When the user
double-clicks a project, the form opens and goes to that specific record.

I currently have 2 identicle forms with two queries to handle this (one for
each button). I know there is a way to do this using a single form and a
single query but I do not know the code. I currently have the following in
place for the "filtered" form:

In the query (qryProjectFiltered) I have the following in the criteria of
the Project ID field:
[forms]![SwitchBoard1]![ListProjects]

In the list box (ListProjects) on the Switchboard I have the following event
procedure in the "On Dbl Click" event.
DoCmd.OpenForm "frmEditProjStatusFiltered"

Is there a string that can be used such that "If button 1, goto new record,
else [forms]![SwitchBoard1]![ListProjects]? And if so, would the code remain
in the criteria for the Project ID field?

Thank you very much in advance for your assistance.
 
O

Ofer

From the Add button run as follow
docmd.OpenForm "FormName",,,,acFormAdd

And From the edit button
WhereCondition="Project="& me.project 'If project Number
WhereCondition="Project='"& me.project & "'" 'If project String
docmd.OpenForm "FormName",,,WhereCondition,acFormEdit
 
S

snichols

I'm sorry. This has confused me (not difficult to do). About the "And From
the edit button" from below. Am I to simply insert that code as an Event
Procedure for the On click event of the button?

Ofer said:
From the Add button run as follow
docmd.OpenForm "FormName",,,,acFormAdd

And From the edit button
WhereCondition="Project="& me.project 'If project Number
WhereCondition="Project='"& me.project & "'" 'If project String
docmd.OpenForm "FormName",,,WhereCondition,acFormEdit


snichols said:
Hi. I have a Switchboard with two buttons that should open the same form
(frmEditProjectStatus) as follows:

Button 1- Used to add a new record. No problems with this one.
Button 2- Used to make a combo box visible. When a user selects his/her name
from the combo box a list of that user's projects is shown. When the user
double-clicks a project, the form opens and goes to that specific record.

I currently have 2 identicle forms with two queries to handle this (one for
each button). I know there is a way to do this using a single form and a
single query but I do not know the code. I currently have the following in
place for the "filtered" form:

In the query (qryProjectFiltered) I have the following in the criteria of
the Project ID field:
[forms]![SwitchBoard1]![ListProjects]

In the list box (ListProjects) on the Switchboard I have the following event
procedure in the "On Dbl Click" event.
DoCmd.OpenForm "frmEditProjStatusFiltered"

Is there a string that can be used such that "If button 1, goto new record,
else [forms]![SwitchBoard1]![ListProjects]? And if so, would the code remain
in the criteria for the Project ID field?

Thank you very much in advance for your assistance.
 
O

Ofer

Yes, from ever you want to run the form and how, edit or add

snichols said:
I'm sorry. This has confused me (not difficult to do). About the "And From
the edit button" from below. Am I to simply insert that code as an Event
Procedure for the On click event of the button?

Ofer said:
From the Add button run as follow
docmd.OpenForm "FormName",,,,acFormAdd

And From the edit button
WhereCondition="Project="& me.project 'If project Number
WhereCondition="Project='"& me.project & "'" 'If project String
docmd.OpenForm "FormName",,,WhereCondition,acFormEdit


snichols said:
Hi. I have a Switchboard with two buttons that should open the same form
(frmEditProjectStatus) as follows:

Button 1- Used to add a new record. No problems with this one.
Button 2- Used to make a combo box visible. When a user selects his/her name
from the combo box a list of that user's projects is shown. When the user
double-clicks a project, the form opens and goes to that specific record.

I currently have 2 identicle forms with two queries to handle this (one for
each button). I know there is a way to do this using a single form and a
single query but I do not know the code. I currently have the following in
place for the "filtered" form:

In the query (qryProjectFiltered) I have the following in the criteria of
the Project ID field:
[forms]![SwitchBoard1]![ListProjects]

In the list box (ListProjects) on the Switchboard I have the following event
procedure in the "On Dbl Click" event.
DoCmd.OpenForm "frmEditProjStatusFiltered"

Is there a string that can be used such that "If button 1, goto new record,
else [forms]![SwitchBoard1]![ListProjects]? And if so, would the code remain
in the criteria for the Project ID field?

Thank you very much in advance for your assistance.
 
Top