selection in control determines control of other forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, and thanks for reading my question.

I have 3 forms, a Main form which shows a general overview, and then a
couple other forms which show more specific data. All 3 forms come from the
same table, so no relationships are involved. (yet)

When I select a specific type of candy in my primary key field, Candy, on my
first form, view the data there, and then click on the button to go to the
second or third form, I'd like it to still have the same Candy on that form.
I don't really know what this is called, but I believe it is when a control
on one form determines the control on another form.

For example, I select "Snickers" on my main form, view it's data, then go to
my second form by clicking on the 2nd form button, it's now on "M&Ms" instead
of "Snickers" like I would like it to be. I have to search again for
"Snickers" in my 2nd form to get to the data. It's a pain, and I imagine it
will be for the database users as well.

Thanks so much.

-Blenvid

BTW- my database isn't about candy, I just used this description because
Halloween's got me thinking about candy!!!! Ummmm Mr. Goodbar
 
You can use the WhereCondition in the open report command line, to open the
second or the third form with the desire record

Dim MyWhereCond As String
MyWhereCond = "[InsertHereCandyNameFieldNameInTheTable] = '" &
Me.[InsertHereCandyNameFieldNameInTheForm] & "'"
Docmd.OpenForm "FormName",,,MyWhereCond
========================================
If you filter the record using a number field then use
Dim MyWhereCond As String
MyWhereCond = "[InsertHereCandyNameFieldNameInTheTable] = " &
Me.[InsertHereCandyNameFieldNameInTheForm]
Docmd.OpenForm "FormName",,,MyWhereCond
 
Hi, Blenvid.

Use the Where parameter of the OpenForm method. If you enable the wizard in
form design view (View, Toolbox, toggle on the button with the wand and
stars), it will write the code for you. Select Form Operations, Open Form,
and select the option "With Specific Data to Display". It will write
something like the following:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourNewForm"

stLinkCriteria = "[KeyField]=" & Me![YourMatchingControlOnCurrentForm]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Hope that helps.
Sprinks
 
Hey guys,

Thanks so much for getting back to me so quickly. I'll take a look at these
solutions today, then get back to you with a new post to let you know how
things go.

Thanks again.

-Blenvid
 
Hi Sprinks,

My wizard is enabled so that's ok, but I can't find a "Form Operations"
button or menu. Hopefully once I find out where this is, I'll be able to
continue.

Thanks.

-Blenvid

Sprinks said:
Hi, Blenvid.

Use the Where parameter of the OpenForm method. If you enable the wizard in
form design view (View, Toolbox, toggle on the button with the wand and
stars), it will write the code for you. Select Form Operations, Open Form,
and select the option "With Specific Data to Display". It will write
something like the following:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourNewForm"

stLinkCriteria = "[KeyField]=" & Me![YourMatchingControlOnCurrentForm]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Hope that helps.
Sprinks



Blenvid said:
Hello, and thanks for reading my question.

I have 3 forms, a Main form which shows a general overview, and then a
couple other forms which show more specific data. All 3 forms come from the
same table, so no relationships are involved. (yet)

When I select a specific type of candy in my primary key field, Candy, on my
first form, view the data there, and then click on the button to go to the
second or third form, I'd like it to still have the same Candy on that form.
I don't really know what this is called, but I believe it is when a control
on one form determines the control on another form.

For example, I select "Snickers" on my main form, view it's data, then go to
my second form by clicking on the 2nd form button, it's now on "M&Ms" instead
of "Snickers" like I would like it to be. I have to search again for
"Snickers" in my 2nd form to get to the data. It's a pain, and I imagine it
will be for the database users as well.

Thanks so much.

-Blenvid

BTW- my database isn't about candy, I just used this description because
Halloween's got me thinking about candy!!!! Ummmm Mr. Goodbar
 
Hi Ofer,

Where is the "open report command line?" I can get to the forms Event tab of
the form I'm editing, where it has "On Load," "On Current" etc... Is this
where you mean? Please assist.

Thanks.

-Blenvid

Ofer said:
You can use the WhereCondition in the open report command line, to open the
second or the third form with the desire record

Dim MyWhereCond As String
MyWhereCond = "[InsertHereCandyNameFieldNameInTheTable] = '" &
Me.[InsertHereCandyNameFieldNameInTheForm] & "'"
Docmd.OpenForm "FormName",,,MyWhereCond
========================================
If you filter the record using a number field then use
Dim MyWhereCond As String
MyWhereCond = "[InsertHereCandyNameFieldNameInTheTable] = " &
Me.[InsertHereCandyNameFieldNameInTheForm]
Docmd.OpenForm "FormName",,,MyWhereCond

--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



Blenvid said:
Hello, and thanks for reading my question.

I have 3 forms, a Main form which shows a general overview, and then a
couple other forms which show more specific data. All 3 forms come from the
same table, so no relationships are involved. (yet)

When I select a specific type of candy in my primary key field, Candy, on my
first form, view the data there, and then click on the button to go to the
second or third form, I'd like it to still have the same Candy on that form.
I don't really know what this is called, but I believe it is when a control
on one form determines the control on another form.

For example, I select "Snickers" on my main form, view it's data, then go to
my second form by clicking on the 2nd form button, it's now on "M&Ms" instead
of "Snickers" like I would like it to be. I have to search again for
"Snickers" in my 2nd form to get to the data. It's a pain, and I imagine it
will be for the database users as well.

Thanks so much.

-Blenvid

BTW- my database isn't about candy, I just used this description because
Halloween's got me thinking about candy!!!! Ummmm Mr. Goodbar
 
Hi, Blenvid
First, it is my mistake, it should be the "WhereCondition in the open form
command line" and not report.
As you can see in the example I gave in the first post.

--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



Blenvid said:
Hi Ofer,

Where is the "open report command line?" I can get to the forms Event tab of
the form I'm editing, where it has "On Load," "On Current" etc... Is this
where you mean? Please assist.

Thanks.

-Blenvid

Ofer said:
You can use the WhereCondition in the open report command line, to open the
second or the third form with the desire record

Dim MyWhereCond As String
MyWhereCond = "[InsertHereCandyNameFieldNameInTheTable] = '" &
Me.[InsertHereCandyNameFieldNameInTheForm] & "'"
Docmd.OpenForm "FormName",,,MyWhereCond
========================================
If you filter the record using a number field then use
Dim MyWhereCond As String
MyWhereCond = "[InsertHereCandyNameFieldNameInTheTable] = " &
Me.[InsertHereCandyNameFieldNameInTheForm]
Docmd.OpenForm "FormName",,,MyWhereCond

--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



Blenvid said:
Hello, and thanks for reading my question.

I have 3 forms, a Main form which shows a general overview, and then a
couple other forms which show more specific data. All 3 forms come from the
same table, so no relationships are involved. (yet)

When I select a specific type of candy in my primary key field, Candy, on my
first form, view the data there, and then click on the button to go to the
second or third form, I'd like it to still have the same Candy on that form.
I don't really know what this is called, but I believe it is when a control
on one form determines the control on another form.

For example, I select "Snickers" on my main form, view it's data, then go to
my second form by clicking on the 2nd form button, it's now on "M&Ms" instead
of "Snickers" like I would like it to be. I have to search again for
"Snickers" in my 2nd form to get to the data. It's a pain, and I imagine it
will be for the database users as well.

Thanks so much.

-Blenvid

BTW- my database isn't about candy, I just used this description because
Halloween's got me thinking about candy!!!! Ummmm Mr. Goodbar
 
Hi Ofer,

That's ok; I assumed you meant open form. You referred to form instead of
reposrt everywhere else.

Where do I put this code Ofer? Anywhere in the code for the form?

Thanks!

-Blenvid

Ofer said:
Hi, Blenvid
First, it is my mistake, it should be the "WhereCondition in the open form
command line" and not report.
As you can see in the example I gave in the first post.

--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



Blenvid said:
Hi Ofer,

Where is the "open report command line?" I can get to the forms Event tab of
the form I'm editing, where it has "On Load," "On Current" etc... Is this
where you mean? Please assist.

Thanks.

-Blenvid

Ofer said:
You can use the WhereCondition in the open report command line, to open the
second or the third form with the desire record

Dim MyWhereCond As String
MyWhereCond = "[InsertHereCandyNameFieldNameInTheTable] = '" &
Me.[InsertHereCandyNameFieldNameInTheForm] & "'"
Docmd.OpenForm "FormName",,,MyWhereCond
========================================
If you filter the record using a number field then use
Dim MyWhereCond As String
MyWhereCond = "[InsertHereCandyNameFieldNameInTheTable] = " &
Me.[InsertHereCandyNameFieldNameInTheForm]
Docmd.OpenForm "FormName",,,MyWhereCond

--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



:

Hello, and thanks for reading my question.

I have 3 forms, a Main form which shows a general overview, and then a
couple other forms which show more specific data. All 3 forms come from the
same table, so no relationships are involved. (yet)

When I select a specific type of candy in my primary key field, Candy, on my
first form, view the data there, and then click on the button to go to the
second or third form, I'd like it to still have the same Candy on that form.
I don't really know what this is called, but I believe it is when a control
on one form determines the control on another form.

For example, I select "Snickers" on my main form, view it's data, then go to
my second form by clicking on the 2nd form button, it's now on "M&Ms" instead
of "Snickers" like I would like it to be. I have to search again for
"Snickers" in my 2nd form to get to the data. It's a pain, and I imagine it
will be for the database users as well.

Thanks so much.

-Blenvid

BTW- my database isn't about candy, I just used this description because
Halloween's got me thinking about candy!!!! Ummmm Mr. Goodbar
 
Create a button on the Form, and on the OnClick event of the button run the
code of the OpenForm
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



Blenvid said:
Hi Ofer,

That's ok; I assumed you meant open form. You referred to form instead of
reposrt everywhere else.

Where do I put this code Ofer? Anywhere in the code for the form?

Thanks!

-Blenvid

Ofer said:
Hi, Blenvid
First, it is my mistake, it should be the "WhereCondition in the open form
command line" and not report.
As you can see in the example I gave in the first post.

--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



Blenvid said:
Hi Ofer,

Where is the "open report command line?" I can get to the forms Event tab of
the form I'm editing, where it has "On Load," "On Current" etc... Is this
where you mean? Please assist.

Thanks.

-Blenvid

:

You can use the WhereCondition in the open report command line, to open the
second or the third form with the desire record

Dim MyWhereCond As String
MyWhereCond = "[InsertHereCandyNameFieldNameInTheTable] = '" &
Me.[InsertHereCandyNameFieldNameInTheForm] & "'"
Docmd.OpenForm "FormName",,,MyWhereCond
========================================
If you filter the record using a number field then use
Dim MyWhereCond As String
MyWhereCond = "[InsertHereCandyNameFieldNameInTheTable] = " &
Me.[InsertHereCandyNameFieldNameInTheForm]
Docmd.OpenForm "FormName",,,MyWhereCond

--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



:

Hello, and thanks for reading my question.

I have 3 forms, a Main form which shows a general overview, and then a
couple other forms which show more specific data. All 3 forms come from the
same table, so no relationships are involved. (yet)

When I select a specific type of candy in my primary key field, Candy, on my
first form, view the data there, and then click on the button to go to the
second or third form, I'd like it to still have the same Candy on that form.
I don't really know what this is called, but I believe it is when a control
on one form determines the control on another form.

For example, I select "Snickers" on my main form, view it's data, then go to
my second form by clicking on the 2nd form button, it's now on "M&Ms" instead
of "Snickers" like I would like it to be. I have to search again for
"Snickers" in my 2nd form to get to the data. It's a pain, and I imagine it
will be for the database users as well.

Thanks so much.

-Blenvid

BTW- my database isn't about candy, I just used this description because
Halloween's got me thinking about candy!!!! Ummmm Mr. Goodbar
 
Thanks. There was already some code there, code to bring up the form, so I
combined your code with the code that was already there; here is my resulting
code. Please let me know if this looks good, or needs some work.

----------------------

Private Sub btn_ServerAssetInformation_Click()
On Error GoTo Err_btn_ServerAssetInformation_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim myWhereCond As String

myWhereCond = "[serverName] = '" & Me.[serverName] & "'"


stDocName = "frm_ServerAssetInfo"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.OpenForm stDocName, , , myWhereCond

Exit_btn_ServerAssetInformation_Click:
Exit Sub

Err_btn_ServerAssetInformation_Click:
MsgBox Err.Description
Resume Exit_btn_ServerAssetInformation_Click

End Sub
---------------------------------------------

-Blenvid

Ofer said:
Create a button on the Form, and on the OnClick event of the button run the
code of the OpenForm
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



Blenvid said:
Hi Ofer,

That's ok; I assumed you meant open form. You referred to form instead of
reposrt everywhere else.

Where do I put this code Ofer? Anywhere in the code for the form?

Thanks!

-Blenvid

Ofer said:
Hi, Blenvid
First, it is my mistake, it should be the "WhereCondition in the open form
command line" and not report.
As you can see in the example I gave in the first post.

--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



:

Hi Ofer,

Where is the "open report command line?" I can get to the forms Event tab of
the form I'm editing, where it has "On Load," "On Current" etc... Is this
where you mean? Please assist.

Thanks.

-Blenvid

:

You can use the WhereCondition in the open report command line, to open the
second or the third form with the desire record

Dim MyWhereCond As String
MyWhereCond = "[InsertHereCandyNameFieldNameInTheTable] = '" &
Me.[InsertHereCandyNameFieldNameInTheForm] & "'"
Docmd.OpenForm "FormName",,,MyWhereCond
========================================
If you filter the record using a number field then use
Dim MyWhereCond As String
MyWhereCond = "[InsertHereCandyNameFieldNameInTheTable] = " &
Me.[InsertHereCandyNameFieldNameInTheForm]
Docmd.OpenForm "FormName",,,MyWhereCond

--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



:

Hello, and thanks for reading my question.

I have 3 forms, a Main form which shows a general overview, and then a
couple other forms which show more specific data. All 3 forms come from the
same table, so no relationships are involved. (yet)

When I select a specific type of candy in my primary key field, Candy, on my
first form, view the data there, and then click on the button to go to the
second or third form, I'd like it to still have the same Candy on that form.
I don't really know what this is called, but I believe it is when a control
on one form determines the control on another form.

For example, I select "Snickers" on my main form, view it's data, then go to
my second form by clicking on the 2nd form button, it's now on "M&Ms" instead
of "Snickers" like I would like it to be. I have to search again for
"Snickers" in my 2nd form to get to the data. It's a pain, and I imagine it
will be for the database users as well.

Thanks so much.

-Blenvid

BTW- my database isn't about candy, I just used this description because
Halloween's got me thinking about candy!!!! Ummmm Mr. Goodbar
 
It's look fine, just remove this line
DoCmd.OpenForm stDocName, , , stLinkCriteria

Its not relavent any more
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



Blenvid said:
Thanks. There was already some code there, code to bring up the form, so I
combined your code with the code that was already there; here is my resulting
code. Please let me know if this looks good, or needs some work.

----------------------

Private Sub btn_ServerAssetInformation_Click()
On Error GoTo Err_btn_ServerAssetInformation_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim myWhereCond As String

myWhereCond = "[serverName] = '" & Me.[serverName] & "'"


stDocName = "frm_ServerAssetInfo"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.OpenForm stDocName, , , myWhereCond

Exit_btn_ServerAssetInformation_Click:
Exit Sub

Err_btn_ServerAssetInformation_Click:
MsgBox Err.Description
Resume Exit_btn_ServerAssetInformation_Click

End Sub
---------------------------------------------

-Blenvid

Ofer said:
Create a button on the Form, and on the OnClick event of the button run the
code of the OpenForm
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



Blenvid said:
Hi Ofer,

That's ok; I assumed you meant open form. You referred to form instead of
reposrt everywhere else.

Where do I put this code Ofer? Anywhere in the code for the form?

Thanks!

-Blenvid

:

Hi, Blenvid
First, it is my mistake, it should be the "WhereCondition in the open form
command line" and not report.
As you can see in the example I gave in the first post.

--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



:

Hi Ofer,

Where is the "open report command line?" I can get to the forms Event tab of
the form I'm editing, where it has "On Load," "On Current" etc... Is this
where you mean? Please assist.

Thanks.

-Blenvid

:

You can use the WhereCondition in the open report command line, to open the
second or the third form with the desire record

Dim MyWhereCond As String
MyWhereCond = "[InsertHereCandyNameFieldNameInTheTable] = '" &
Me.[InsertHereCandyNameFieldNameInTheForm] & "'"
Docmd.OpenForm "FormName",,,MyWhereCond
========================================
If you filter the record using a number field then use
Dim MyWhereCond As String
MyWhereCond = "[InsertHereCandyNameFieldNameInTheTable] = " &
Me.[InsertHereCandyNameFieldNameInTheForm]
Docmd.OpenForm "FormName",,,MyWhereCond

--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



:

Hello, and thanks for reading my question.

I have 3 forms, a Main form which shows a general overview, and then a
couple other forms which show more specific data. All 3 forms come from the
same table, so no relationships are involved. (yet)

When I select a specific type of candy in my primary key field, Candy, on my
first form, view the data there, and then click on the button to go to the
second or third form, I'd like it to still have the same Candy on that form.
I don't really know what this is called, but I believe it is when a control
on one form determines the control on another form.

For example, I select "Snickers" on my main form, view it's data, then go to
my second form by clicking on the 2nd form button, it's now on "M&Ms" instead
of "Snickers" like I would like it to be. I have to search again for
"Snickers" in my 2nd form to get to the data. It's a pain, and I imagine it
will be for the database users as well.

Thanks so much.

-Blenvid

BTW- my database isn't about candy, I just used this description because
Halloween's got me thinking about candy!!!! Ummmm Mr. Goodbar
 
Back
Top