By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,577 Members | 864 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,577 IT Pros & Developers. It's quick & easy.

OnClick event works w/ command button but not image box?

P: n/a
I have a continuous form. there is a command button with the following code
for the OnClick event:

DoCmd.OpenForm "frmPlants", , , "PlantsID =" & Me!PlantsID

I click the button and frmPlants opens up with the record that corresponds
to the one on the cont. form.

I put that same code for the OnClick of an image control (i.e. the user
clicks a little icon to open the form instead of a button) and frmPlants
opens but to the first record on the continuous form.

What gives?
Jul 8 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Where does the record selector point? Is it to the first record of the
continuous form? If so, that's the active record. Where is the image control
located, is it in the detail section of the continuous form?

I tested this and I show that clicking on the image control doesn't move the
focus to the current record. As a work around, I placed a command button
over the image control, sizing it exactly the same as the image control, and
setting the command button's Transparent property to Yes. This make the
command button invisible to the user, but will allow things to work as you
want. Place the code in this command button's Click event.

--
Wayne Morgan
MS Access MVP
"John Smith" <so*****@microsoft.comwrote in message
news:pR*******************@fe09.news.easynews.com. ..
>I have a continuous form. there is a command button with the following code
for the OnClick event:

DoCmd.OpenForm "frmPlants", , , "PlantsID =" & Me!PlantsID

I click the button and frmPlants opens up with the record that corresponds
to the one on the cont. form.

I put that same code for the OnClick of an image control (i.e. the user
clicks a little icon to open the form instead of a button) and frmPlants
opens but to the first record on the continuous form.

What gives?


Jul 8 '06 #2

P: n/a
"Wayne Morgan" <co***************************@hotmail.comwrote in message
news:o_********************@newssvr13.news.prodigy .com...
Where does the record selector point? Is it to the first record of the
continuous form? If so, that's the active record. Where is the image
control located, is it in the detail section of the continuous form?
The record selector points to the first record. If I click the command
button (there is one per record) the focus goes to the record of the button
I clicked, thus the form opens for that record. If I click the image, the
record selector does not change, ie. focus remains on the first record (or
more specifically, the last record that had the focus.)
I tested this and I show that clicking on the image control doesn't move
the focus to the current record. As a work around, I placed a command
button over the image control, sizing it exactly the same as the image
control, and setting the command button's Transparent property to Yes.
This make the command button invisible to the user, but will allow things
to work as you want. Place the code in this command button's Click event.
This is what I did as well, I am still, however, curious/confused as to why
the exact same line of code, for the same event would not operate the same?
Jul 8 '06 #3

P: n/a
The line of code IS operating the same. The value is being passed from the
current record. As you also noted, the record selector doesn't move when you
click on the image control, so the record ID that is being passed is the one
for where the record selector is located. The problem isn't the code, it's
that the record selector isn't moving. Apparently, the image control isn't
able to receive the focus, so the record doesn't get selected and the cursor
doesn't move.

--
Wayne Morgan
MS Access MVP
"John Smith" <so*****@microsoft.comwrote in message
news:rG********************@fe03.news.easynews.com ...
"Wayne Morgan" <co***************************@hotmail.comwrote in
message news:o_********************@newssvr13.news.prodigy .com...
>Where does the record selector point? Is it to the first record of the
continuous form? If so, that's the active record. Where is the image
control located, is it in the detail section of the continuous form?

The record selector points to the first record. If I click the command
button (there is one per record) the focus goes to the record of the
button I clicked, thus the form opens for that record. If I click the
image, the record selector does not change, ie. focus remains on the first
record (or more specifically, the last record that had the focus.)
>I tested this and I show that clicking on the image control doesn't move
the focus to the current record. As a work around, I placed a command
button over the image control, sizing it exactly the same as the image
control, and setting the command button's Transparent property to Yes.
This make the command button invisible to the user, but will allow things
to work as you want. Place the code in this command button's Click event.

This is what I did as well, I am still, however, curious/confused as to
why the exact same line of code, for the same event would not operate the
same?


Jul 9 '06 #4

P: n/a
I think you are right. When I click a command button, the first thing that
happens is the focus moves to that button and then the code is run, thus the
focus is on that particular record before the code tells it to filter for a
specific field. The image control does not recieve the focus before running
the code thus, I am still on the last record.

"Wayne Morgan" <co***************************@hotmail.comwrote in message
news:gC******************@newssvr14.news.prodigy.c om...
The line of code IS operating the same. The value is being passed from the
current record. As you also noted, the record selector doesn't move when
you click on the image control, so the record ID that is being passed is
the one for where the record selector is located. The problem isn't the
code, it's that the record selector isn't moving. Apparently, the image
control isn't able to receive the focus, so the record doesn't get
selected and the cursor doesn't move.

--
Wayne Morgan
MS Access MVP
"John Smith" <so*****@microsoft.comwrote in message
news:rG********************@fe03.news.easynews.com ...
>"Wayne Morgan" <co***************************@hotmail.comwrote in
message news:o_********************@newssvr13.news.prodigy .com...
>>Where does the record selector point? Is it to the first record of the
continuous form? If so, that's the active record. Where is the image
control located, is it in the detail section of the continuous form?

The record selector points to the first record. If I click the command
button (there is one per record) the focus goes to the record of the
button I clicked, thus the form opens for that record. If I click the
image, the record selector does not change, ie. focus remains on the
first record (or more specifically, the last record that had the focus.)
>>I tested this and I show that clicking on the image control doesn't move
the focus to the current record. As a work around, I placed a command
button over the image control, sizing it exactly the same as the image
control, and setting the command button's Transparent property to Yes.
This make the command button invisible to the user, but will allow
things to work as you want. Place the code in this command button's
Click event.

This is what I did as well, I am still, however, curious/confused as to
why the exact same line of code, for the same event would not operate the
same?



Jul 10 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.