Access Continuous Forms: Row highlighting + DBLclick functionality (1 Viewer)

ironfelix717

Registered User.
Local time
Today, 10:24
Joined
Sep 20, 2019
Messages
193
Hi all,

I've finally delved into continuous forms and am enjoying this new discovery. What led me here was the need for a Data Grid / Editable listbox control that i've been dancing around with a lousy (but functional) custom form control. Therefore, my end goal of this form is to simulate such a control using a continuous form.

This topic has 2 questions within it and probably stem from my inexperience with continuous forms.

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

1.) Row Formatting - Substitute conditional format for code solution
I was able to achieve "row" highlighting using the conditional formatting method, which i discovered here: LINK (thank you)
However, conditional formatting appears to be limited (outline formatting? other properties?). So, i was wondering if there is any way to format the "row" with a code event. I tried and tried to format the "row" in the OnCurrent event, etc etc, and could not get past the fact that I was formatting every single row in the form - rather than just the selected row, which makes continuous forms conceptually a bit confusing for me as it relates to events.

2.) Disable textbox entry, allow on DBL Click
The next feature I would like to solve is preventing/handling the auto textbox entry on the form. When a textbox is selected in a continuous form it is immediately entered and ready to accept input. I would prefer if the user had to "enable" the textbox themselves using a double-click. That is the most natural approach. Preventing the textbox from auto-entering on click helps prevent accidental data changes, etc. (yeah, you could just lock the control too, etc. - but it still enters which is awkward IMO).

The solution i initially considered was setting Enabled = False on the textbox in question, and then using DBL Click to re-enable it, but then i remembered disabling the control disabled the events, so no dice there.


Example attached!
 

Attachments

  • Continuous Form Ex..accdb
    3.4 MB · Views: 247

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:24
Joined
May 7, 2009
Messages
19,169
1. use the Detail section's Paint event.
2. use the control's Locked property.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 14:24
Joined
Feb 19, 2013
Messages
16,553
could not get past the fact that I was formatting every single row in the form - rather than just the selected row
your row needs contain a unique ID, your current event will populate a hidden textbox with that uniqueiD, your expression would be

expression is....[id]=[hiddentextboxname]

with regards additional formatting methods (for the contents, not the borders) using the format property or richtext can often work - really depends on what you are trying to do.

don't understand this 'you could just lock the control too, etc. - but it still enters which is awkward IMO'. You need to be able to give the control focus in order to trigger events. so they can highlight the contents, sort or filter on it, but they can't change the value

unlock the control on double click, relock on on lost focus, perhaps also change the background colour which combined with conditional formatting could keep the other rows for that column 'greyed out'
 

ironfelix717

Registered User.
Local time
Today, 10:24
Joined
Sep 20, 2019
Messages
193
Hi, thanks for the help.



For (1) formatting:
To clarify: when i say "formatting" I am discussing formatting borders, colors, etc, and not the data. I was unable to get the On Paint event to work. The same result occurred: every row highlighted. I need to see a code example to have any idea how this works in a continuous form.

OnPaint still does nothing but format every single row:

Code:
Private Sub Form_Current()

tbcurrent = Me.LineNo  'for conditional formatting (rowcolor)

End Sub

Private Sub Detail_Paint()

tbPartnumber.BorderColor = vbRed
tbPartnumber.BorderStyle = 3

End Sub


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

For (2):

don't understand this 'you could just lock the control too, etc. - but it still enters which is awkward IMO'. You need to be able to give the control focus in order to trigger events. so they can highlight the contents, sort or filter on it, but they can't change the value

You both recommended locking the control --- doesn't solve the problem I laid out in my post. I am not trying to eliminate the ability to edit the data. I am trying to eliminate the textbox even being entered when clicked, which seems to be inherent to this type of form. Therefore, I am trying to highlight the row, without giving focus to the textbox that is selected - until the user dbl clicks.

With this continuous form, when a textbox is selected, not only does it get focus, it changes the entire background the textbox to white.


**Attached is GIF of how this form should function:
Subscript.gif
 

ironfelix717

Registered User.
Local time
Today, 10:24
Joined
Sep 20, 2019
Messages
193
Update:

I guess i sort of solved item 2:
I was overthinking it perhaps.

(This works for just one of the textboxes) - though I would prefer to not write code for every On_Click event for each textbox.
Code:
Private Sub tbPartnumber_Click()
tbcurrent.SetFocus  'move focus out of clicked textbox
End Sub

Private Sub tbPartnumber_DblClick(Cancel As Integer)
tbPartnumber.SetFocus
End Sub


Update #2:

A lot of the issues i'm having are rooted in the fact that I don't understand how to effect only the selected row in a continuous form. The whole concept is odd.

Anyway: The approach above (moving focus) is kinda lousy. Its glitchy and slightly slows down the form... The cleanest method is finding a way to have the controls disabled, but then enabled on double click. Even if it wasn't unlocked by control, but rather by entire row, that would be OK.

So, i investigated that and have a solution, but not entirely because, again, I don't know how to effect only the selected row in a continuous form OTHER than conditional formatting, like my OP states.
Code:
Private Sub Detail_Click()
'LOCK THE ROW
EnableControls False
End Sub

Private Sub Detail_DblClick(Cancel As Integer)
'UNLOCK THE ROW

If tbPartnumber.enabled = False Then
    
    EnableControls True
End If
    
End Sub

Private Sub EnableControls(enabled As Boolean)
Dim ctl         As Control
For Each ctl In Me.Controls
    If ctl.Tag = "ROW" Then
        
        ctl.enabled = enabled
    End If
Next ctl
End Sub
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:24
Joined
May 7, 2009
Messages
19,169
here is a Concrete example of Paint Event.
just as with Conditional Format, you add Condition on it
so that only those that meet the condition are formatted.
 

Attachments

  • paint.zip
    33.8 KB · Views: 230

ironfelix717

Registered User.
Local time
Today, 10:24
Joined
Sep 20, 2019
Messages
193
here is a Concrete example of Paint Event.
just as with Conditional Format, you add Condition on it
so that only those that meet the condition are formatted.


Hi,

Thanks for your example. I see what you are explaining, but i am unsure how this allows me to conditional format the selected row, simply based on a selection.

hmmmmm. Only way I can tell is by conditional formatting feature.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 14:24
Joined
Feb 19, 2013
Messages
16,553
to prevent the control from retaining focus, move the focus to another control. That control could be existing or create a new one which would be visible, but height and width set to zero

private sub myControl_gotfocus()
mylittltextbox.setfocus
end sub

don't forget users can navigate between controls using the keyboard as well as the mouse
 

ironfelix717

Registered User.
Local time
Today, 10:24
Joined
Sep 20, 2019
Messages
193
Both problems seem to be related in that if I can figure out a way to affect only the controls in the row with focus, I can solve the rest.

Is there any way to do this?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 14:24
Joined
Feb 19, 2013
Messages
16,553
don't understand how to effect only the selected row in a continuous form. The whole concept is odd.
Not really, a continuous form only has one 'row' of controls which are repeated for each record.

See the attached modified version of Arnelgp's suggestion. Is this what you mean? it applies the principle I outlined on post #3
 

Attachments

  • paint - vCJ.zip
    38.7 KB · Views: 213

ironfelix717

Registered User.
Local time
Today, 10:24
Joined
Sep 20, 2019
Messages
193
Hi,

Your example does exactly as I requested: effect only the selected row in a continuous form

The problem now is the formatting is only applied when the item/row has focus. Move the focus away to the currentID textbox and the formatting disappears.

-------

I suspect what I am trying to achieve really isn't possible to achieve "elegantly" . I'll post my final mock-up for any others who might want to simulate a proper editable listbox control.

We need a data grid control / proper editable listbox. How this type of control never actually got implemented in Access at the start makes my mind implode several thousand times.


Thanks for your contributions --
 

ironfelix717

Registered User.
Local time
Today, 10:24
Joined
Sep 20, 2019
Messages
193
Final solution:

Subscript2.gif
 

Attachments

  • Continuous Form Ex..accdb
    3.4 MB · Views: 277

Users who are viewing this thread

Top Bottom