Continuous form - current vs selected record on cmd click (1 Viewer)

wiklendt

i recommend chocolate
Local time
Tomorrow, 02:47
Joined
Mar 10, 2008
Messages
1,746
Hi,

in my continuous form i have three images each with onClick events. when user presses one of these images, the code is executed for the 'current' record, not necessarily the one that the user clicked on. How can i make access acknowledge the record that the user wants?

I have tried setting focus to another textbox in the record in the onclick event, but this simply sets focus in the 'current' record, not the selected one.

The discussion here is similar to my problem, but without resolution.

My images depict for the user whether or not an attachment has been added to the record and the ability to view or remove it, or otherwise add an attachment. I use conditional formatting for a bound textbox under the image to make the image 'visible' (the image is a black outline icon, the textbox underneath is also black, effectively hiding the icon until the conditional format criteria are met, then the textbox is formatted green and the icons become 'visible'.) I have set it up this way because my form is space-poor and it is an otherwise elegant way of showing the user at a glance the status of attachment and what they can do with it.

I can add an image later if people request it, my internet connection at this point isn't strong enough to bring up the attachment manager window of this post....
 
Maybe this can help.

PHP:
'Open Form With Picture Of Product.

 Dim strFormName As String
    Dim strCriteria As String
    
   If IsNull(Me.ProductID) Then         'No Product Entered Yet For Picture to be Displayed.
   MsgBox "You Must Enter a Product First Then Add a Picture"
   Exit Sub
   End If
   
    
   strFormName = "frmProductPicture"
   strCriteria = "[ProductID] = " & Me![ProductID]
   DoCmd.OpenForm strFormName, acViewNormal, , strCriteria
 
Maybe this can help.
Thanks for your reply Burrina, the problem i have is that the ID is for the 'current' record in the continuous form - so, wherever the cursor is, that's the record ID it pulls instead of on the record that the mouse clicked over. So, let's say there are 5 records in the continuous form and my cursor is in the first field of the 1st record. if i suddenly decide i want to click on the command 'button' to view the attachment from the 5th record, access returns the ID from record 1 instead of record 5. if the user moves the cursor to a field in record 5 first, and then hits the 'button', then that's fine, the ID for record 5 is returned. i think it's an issue of the image not being bound, so when it is clicked access runs the event from record where the cursor is - what i want is if i click on the 'button' in a different record, for access to be told to change the current record to where the mouse was clicked. Hope that is clearer?
 
Maybe try this and see if it will work for you.
PHP:
Dim recNum As Long

    recNum = Me.CurrentRecord
    Me.Requery
    DoCmd.GoToRecord acDataForm, "YourForm", acGoTo, recNum
 
Maybe try this and see if it will work for you.
PHP:
Dim recNum As Long

    recNum = Me.CurrentRecord
    Me.Requery
    DoCmd.GoToRecord acDataForm, "YourForm", acGoTo, recNum

Hi burrina,

While this is cool (i didn't know about Me.CurrentRecord), it still is using what Access considers to be the current record, not what a user might consider the current record.

When i debug print Me.CurrentRecord to the immediate window, it returns the record number in that recordset of the current record, so the first displayed record is "1", the second is "2" - so if my cursor is in record 1, but i click on a button on record two, Me.Current record returns 1 because that's where the cursor remains (the button is unbound, so the mouse click does nothing to trigger a current record change).

Though i have the perfect place to use Me.CurrentRecord elsewhere in my database, Thanks!

My problem is that MS Access understands the current record to be where the cursor is, while my users think the current record should be where the mouse is. So when they click on (an unbound) button in a record 5 (but the cursor is on record 1) then Access does not update the current record to record 5, it seems to ignore what the mouse is doing all together.

I'm sure others would have come across this problem in the past - is it something we just have to live with? I was thinking to maybe highlight the current record in "you-can't-miss-it yellow", so the current one is (more) obvious (to the user), but i would prefer a more fool-proof method.
 
Last edited:
Show a scrrenshot or else we are blind.

I presume your buttons are not bound to a field in the data. If that is the case then your code works correctly, since there is only one instance of each button no matter on how many lines it is displayed, and so you need to find another approach. Bind a button to a field . Or use a label or textbot and you could display it in hyperlink format.
 
in my continuous form i have three images each with onClick events. when user presses one of these images, the code is executed for the 'current' record, not necessarily the one that the user clicked on. How can i make access acknowledge the record that the user wants?

Why don't you create 3 commandbuttons and place these over your images, and use the commandbuttons Click_Event to execute your code.

Just set the commandbuttons backstyle property to Transparent to "hide" them.

Just a thought.

JanR
 
Show a scrrenshot or else we are blind.

Finally my internet has kicked in. The long-awaited image. (Look towards bottom right).

attachment.php
 

Attachments

  • individual buttons per record.png
    individual buttons per record.png
    77.7 KB · Views: 4,356
I presume your buttons are not bound to a field in the data.
Yes, that's right. I'm using images in place of buttons, but they are also unbound and have the same limitations.

If that is the case then your code works correctly,
That's right, there is no problem with my code - each button event works beautifully on the current record. Just as access wants it.

Bind a button to a field .
Huh, when i bind my image 'button' to my primary key field, it binds but doesn't appear to change the way access handles the current record on click (i.e., the cursor remains on a different record and as such access continues to consider the other record the current one).
I'll try binding a 'real' button and make it transparent (thanks for letting me know this was a possibility JANR!) so i can see the image (or make the caption the action i want from the button to indicate to the user what the button does)... hopefully that'll make a difference to how access handles current record.

Or use a label or textbox and you could display it in hyperlink format.
Hmm, i use text hyperlinks in datasheet view to imitate button functionality but i never thought of using it on a continuous form - i didn't think a textbox could be bound AND display a different kind of text: not the control source data but custom text that i want, that is, to tell the user what the button does, not what it is related to. I'll think about this second, after trying 'real' buttons.

Thanks everyone, a few avenues to try.
 
Check out Wingdings - those fonts have piles of weird characters looking like your images.
 
Why don't you create 3 commandbuttons and place these over your images, and use the commandbuttons Click_Event to execute your code.

Just set the commandbuttons backstyle property to Transparent to "hide" them.

Just a thought.

JanR

Well, despite my misconceptions about how buttons work on continuous forms, this solution actually worked!

<p>This means the final setup is:
<br>- conditionally formatted textbox underneath the other controls with no events and no binding. black by default, coloured on condition.
<br>- black line icon image over the textbox, with no events and no binding
<br>- command button over the image, with the on click event and transparent set to yes. it appears command buttons can't be bound, but this still worked. perhaps the transparency means the form underneath is clicked and comes into focus?
<p>Thanks for everyone who contributed also - i have learned something new from each of you :-) Agnieszka.
 
Last edited:
command button over the image, with the on click event and transparent set to yes. it appears command buttons can't be bound, but this still worked. perhaps the transparency means the form underneath is clicked and comes into focus?

No a commandbutton when it's clicked moves the focus to that record and makes it the current record so you can refrence the correct record in your code. By making it transparent your users will think they are clicking an image, but the button has to be on top of the image and NOT underneath for this to work.

JanR :)
 

Users who are viewing this thread

Back
Top Bottom