473,406 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

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
4 4776
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
"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Nick72 | last post by:
Hi, I've been reading through tons of posts regarding the problems people have encountered with getting javascript functions to trigger when called from onclick events... But so far, I haven't...
8
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image...
0
by: Diane Yocom | last post by:
I'm very new to ASP.Net and probably jumped in a little over my head, but... I'm trying to create a user control that will control navigation through my site. It's sortof like Amazon.com, where...
1
by: simon | last post by:
If I put button into the header of my DataGrid: <asp:TemplateColumn> <HeaderTemplate><asp:Button ID=btnNew Text="New Type" Runat=server></asp:Button></HeaderTemplate> <ItemTemplate> ..... ...
4
by: sameergn | last post by:
Hi, I have an image in my HTML form which has onclick() handler. There is also a submit button and a text box. Whenever text box has focus and user presses enter, the onclick() event of...
5
by: Stuart Shay | last post by:
Hello All I am working on ASP.NET 1.1 Custom Pager that allows a User to Enter a Number in a TextBox and go to the page selected. Since the OnClick Event does not work in ASP.NET 1.1 for a...
1
by: sourcie | last post by:
I am changing an existing quiz found on "JavaScriptKit.com Multiple Choice Quiz" I have an image. Instead of using the radio buttons with the normal true/false question, I want to place two...
2
by: Sister Ray | last post by:
i'm using the Microsoft Device Emulator to test a web app that i'm developing. The click event isn't fired for neither img or input type=image tags, however in the Internet Explorer Mobile...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.