Solved Highlight backcolor in only 1 input on a continuous form (1 Viewer)

chrisjames25

Registered User.
Local time
Today, 14:06
Joined
Dec 1, 2014
Messages
401
Hi. I'm not sure if this is possible as I cant find away but I thouhgt before i give up i will ask on here.

I have a form with 2 subforms on it.

The first subform lists all my sales orders and the data is presented as a continuous form. On the subform is a command button to click to edit the data and there is also a second command button. When this button is clicked it show the details of thesales order in the second subform.

My problem is that I would like to highlight the line i have just clicked in the 1st subform so I can see which sales order the data now populated in the second form realtes to. Whenever i do a backcolor change on click of comman button it changes the backcolor for every input in subform 1. I beleive this is a limititation of continuous forms but just wondered if anyone smarter than me had figured out a workarond.

My only workaround at the moment can be seen in the image attached whereby on clicking the showdata button it populates the data in the main form just above the second subform. Whilst ok I would rather see the data line i just clicked highlighed in the 1st subform.

Apologies if this is a bit rambly but hopefully it makes sense.

thanks in advance.
 

Attachments

  • Continuous form query.JPG
    Continuous form query.JPG
    144.1 KB · Views: 48

CJ_London

Super Moderator
Staff member
Local time
Today, 14:06
Joined
Feb 19, 2013
Messages
16,614
On my phone but investigate conditional formatting
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:06
Joined
May 21, 2018
Messages
8,529
1. Put a hidden text box on your form. I called mine txtLink
2. in the forms on current event put the PK value into the textbox
Code:
me.txtLink = me.customerID
3. set the conditional format where the current ID = txtLink
Link.png


link2.png
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:06
Joined
May 21, 2018
Messages
8,529
@MajP
Why cannot txtLink be bound please?
I thought it might work, but I tried it and it does not. Everything gets highlighted.

Here is the reason why that does not work. I tested this in code to see the order of events.
Formatting is applied in the Paint event to each row
The current event fires once and then the form is repainted Row by Row. If you did this bound the two values would be the same when the row is painted to the screen and all rows would get highlighted. Since the current event actually happens before the rows are painted that is why you have to do it in code.

I added code to show the results during the painting and current event

Code:
Private Sub Detail_Paint()
  Me.Parent.Text3 = Me.Parent.Text3 & vbCrLf & "paint  CustomerID: " & Me.CustomerID & " TxtLink: " & Me.txtLink
End Sub

Private Sub Form_Current()
  Me.txtLink = Me.CustomerID
  Me.Parent.txtLink = Me.CustomerID
  Me.Parent.Text3 = Me.Parent.Text3 & vbCrLf & "Current  CustomerID: " & Me.CustomerID & " TxtLink: " & Me.txtLink
End Sub

Code:
Current  CustomerID: ALFKI TxtLink: ALFKI

paint  CustomerID: ALFKI TxtLink: ALFKI
paint  CustomerID: ANATR TxtLink: ALFKI
paint  CustomerID: ANTON TxtLink: ALFKI
paint  CustomerID: AROUT TxtLink: ALFKI
paint  CustomerID: BERGS TxtLink: ALFKI
paint  CustomerID: BLAUS TxtLink: ALFKI
paint  CustomerID: BLONP TxtLink: ALFKI
paint  CustomerID: BOLID TxtLink: ALFKI
.....

If I get rid of the code that sets the value of txtlink in the current event and bind it I get the below. See the problem? The value changes for each painted row.
Code:
Current  CustomerID: ALFKI TxtLink: ALFKI

paint  CustomerID: ALFKI TxtLink: ALFKI
paint  CustomerID: ANATR TxtLink: ANATR
paint  CustomerID: ANTON TxtLink: ANTON
paint  CustomerID: AROUT TxtLink: AROUT
paint  CustomerID: BERGS TxtLink: BERGS
paint  CustomerID: BLAUS TxtLink: BLAUS
paint  CustomerID: BLONP TxtLink: BLONP
paint  CustomerID: BOLID TxtLink: BOLID
paint  CustomerID: BONAP TxtLink: BONAP
paint  CustomerID: ALFKI TxtLink: ALFKI
 

Attachments

  • Hilite Linked Continuous.accdb
    2.3 MB · Views: 66

Gasman

Enthusiastic Amateur
Local time
Today, 14:06
Joined
Sep 21, 2011
Messages
14,306
I thought it might work, but I tried it and it does not. Everything gets highlighted.

Here is the reason why that does not work. I tested this in code to see the order of events.
Formatting is applied in the Paint event to each row
The current event fires once and then the form is repainted Row by Row. If you did this bound the two values would be the same when the row is painted to the screen and all rows would get highlighted. Since the current event actually happens before the rows are painted that is why you have to do it in code.

I added code to show the results during the painting and current event

Code:
Private Sub Detail_Paint()
  Me.Parent.Text3 = Me.Parent.Text3 & vbCrLf & "paint  CustomerID: " & Me.CustomerID & " TxtLink: " & Me.txtLink
End Sub

Private Sub Form_Current()
  Me.txtLink = Me.CustomerID
  Me.Parent.txtLink = Me.CustomerID
  Me.Parent.Text3 = Me.Parent.Text3 & vbCrLf & "Current  CustomerID: " & Me.CustomerID & " TxtLink: " & Me.txtLink
End Sub

Code:
Current  CustomerID: ALFKI TxtLink: ALFKI

paint  CustomerID: ALFKI TxtLink: ALFKI
paint  CustomerID: ANATR TxtLink: ALFKI
paint  CustomerID: ANTON TxtLink: ALFKI
paint  CustomerID: AROUT TxtLink: ALFKI
paint  CustomerID: BERGS TxtLink: ALFKI
paint  CustomerID: BLAUS TxtLink: ALFKI
paint  CustomerID: BLONP TxtLink: ALFKI
paint  CustomerID: BOLID TxtLink: ALFKI
.....

If I get rid of the code that sets the value of txtlink in the current event and bind it I get the below. See the problem? The value changes for each painted row.
Code:
Current  CustomerID: ALFKI TxtLink: ALFKI

paint  CustomerID: ALFKI TxtLink: ALFKI
paint  CustomerID: ANATR TxtLink: ANATR
paint  CustomerID: ANTON TxtLink: ANTON
paint  CustomerID: AROUT TxtLink: AROUT
paint  CustomerID: BERGS TxtLink: BERGS
paint  CustomerID: BLAUS TxtLink: BLAUS
paint  CustomerID: BLONP TxtLink: BLONP
paint  CustomerID: BOLID TxtLink: BOLID
paint  CustomerID: BONAP TxtLink: BONAP
paint  CustomerID: ALFKI TxtLink: ALFKI
Thank you. Good to know.
 

chrisjames25

Registered User.
Local time
Today, 14:06
Joined
Dec 1, 2014
Messages
401
1. Put a hidden text box on your form. I called mine txtLink
2. in the forms on current event put the PK value into the textbox
Code:
me.txtLink = me.customerID
3. set the conditional format where the current ID = txtLink
View attachment 111866

View attachment 111867
Hi, basedon what you are typiong to gasman does that mean that the above concept wont work and i have to do the code approach?

THansk for all your help so far.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:06
Joined
May 21, 2018
Messages
8,529
Yes you need an unbound form and a single line of code in the current event.
me.txtLink = me.NameofThePrimaryKey
 

chrisjames25

Registered User.
Local time
Today, 14:06
Joined
Dec 1, 2014
Messages
401
Perfect. It has worked perfectly. Exactly what i needed. Just need to tweak the look and feel but that just form tweaking. Amazing. THanks you so much for your help. Will use this in a lot of other forms also. Your a star.
 

riktek

New member
Local time
Today, 06:06
Joined
Dec 15, 2023
Messages
27
In his recent presentation to our User Group, Kent Gorrell demonstrated his technique for highlighting rows in a continuous view using a sub class.
I'm actually evaluating Kent's technique for implementation in my own framework.

In that vein, I'm wondering elsewhere how to get the hWnd of the Detail section for the current record in continuous forms.

Dev Ashish has posted code to do this for controls, which is handy for scrolling text boxes with the mouse wheel, and I've worked out a still-buggy hack to get the latter to work (-ish) on continuous forms.

There has to be a pony in here somewhere. Any thoughts would be welcome.
 

Users who are viewing this thread

Top Bottom