472,791 Members | 1,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 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 4713
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: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.