Made the colored selected record bar Rx mad by setting default Form Open field (1 Viewer)

mdlueck

Sr. Application Developer
Local time
Today, 16:14
Joined
Jun 23, 2011
Messages
2,631
I am utilizing the Rx for colored selected record bar found here:

"Highlight Current Record in an Access Continuous Form"
http://www.upsizing.co.uk/Art53_Highlight.aspx

With a few minor modifications, such as placing into shared code as much of the code as possible and using a pointer to the form to understand which form is calling the shared code.

Anyway, I wanted to force a group of lookup / picklist forms to the Title field of the form. I force the "move to" via this code:

Code:
  'Force the the UI to the title field control
  MePointer.fldtitle.SetFocus
I have placed that code just after the finding of the correct record... Oh... that bit was not part of the Rx, rather something I added on my own to make the UI more intuitive. So, if the field has a current value, I re-locate that current value when the pick list form opens. That way people are less likely to accidentally change data in the application. (Edit record, top record is selected, and push the Select button = data got changed)

So at the point that the SetFocus is called, the correct record does have focus, and the SetFocus does successfully default the field to the Title field. Just it does not have the green background color that it is suppose to.

Now, something that was in the Rx I use for colored selected record... in the Rx's ChangeBackColour event, I have put a Debug.Print to see what color is being set. I always see the same number, including the time that the SetFocus forces the UI to the Title field.

Code:
'Generic API used for the colored row selection capability
Sub uiutils_GridSetSelectedRowBackgrond(ByRef MePointer As Form)
  On Error Resume Next

  Debug.Print "Reference: " & Screen.ActiveControl.BackColor
  Debug.Print "Before: " & MePointer.fldCurrentID.BackColor

  'Set the current control's background to that of the fldCurrentID
  Screen.ActiveControl.BackColor = MePointer.fldCurrentID.BackColor

  Debug.Print "After: " & MePointer.fldCurrentID.BackColor

End Sub
And I see:

Code:
Reference: 5026082
Before: 5026082
After: 5026082
in the immediate window. Which it should as that hidden control has the green background hard coded into it.

I can click the left arrow, and immediately the Title field background turns green properly. Right arrow back to the Title field, green color remains as it should.

Suggestions as to why I can not successfully force the default field to Title without loosing the Green color?

Oh... I pocked just a bit deeper... the color number is NOT always the same... when I arrow to the ID field and back, the Reference number changes...

Code:
Reference: 16777215
Before: 5026082
After: 5026082
Evidently I can not find out the color of the actual control being set... THAT is what is always the same.


Perhaps could "Screen.ActiveControl.BackColor" be referring to the field on the Edit Part form which is white?

Anyway, any suggestions as to why forcing the default field would not retain the Green color? TIA!
 

Attachments

  • Part_Edit_PickListColoredSelectionIssue.jpg
    Part_Edit_PickListColoredSelectionIssue.jpg
    97.9 KB · Views: 118

vbaInet

AWF VIP
Local time
Today, 21:14
Joined
Jan 22, 2010
Messages
26,374
Quite a lengthy post and I don't have the time to read it through ;) Can you tell me what precisely is the problem?

Also, what is Rx? You're the only that uses that code-speak around here and I reckon a lot of people don't know what it means.

You know very well that ActiveForm returns the currently active form, so why go creating your own pointer? :confused:
 

mdlueck

Sr. Application Developer
Local time
Today, 16:14
Joined
Jun 23, 2011
Messages
2,631
Quite a lengthy post and I don't have the time to read it through ;) Can you tell me what precisely is the problem?

I added this...

Anyway, I wanted to force a group of lookup / picklist forms to the Title field of the form. I force the "move to" via this code:

Code:
  'Force the the UI to the title field control
  MePointer.fldtitle.SetFocus

And now that field has focus but not with the selected record background color. (As shown in the screen capture in the first post)

I can move to the left (ID) field and instantly the field gains the correct color. I can move back to the field, and it still retains the correct color.

Also, what is Rx? You're the only that uses that code-speak around here and I reckon a lot of people don't know what it means.

Prescription... aka Dr writing an Rx.

You know very well that ActiveForm returns the currently active form, so why go creating your own pointer? :confused:

ActiveForm was suggested, perhaps by you vbaInet, in order to be able to move that code into a shared module rather than having it on every form which is a multiple record list. I forget what challenge using ActiveForm was resolving.

Anyway, shortly:

1) Force the UI to move to a consistent field
2) End up without the green selected bar color in that field only

I can not see why specifying the field to be on within the record would break the color bar code. :confused:
 

vbaInet

AWF VIP
Local time
Today, 21:14
Joined
Jan 22, 2010
Messages
26,374
I knew what Rx meant in medical terms but I was of the opinion that you were saying it to mean something else :confused: Very confusing indeed.

I'm still confused what your object is. If you move to the control, isn't it the Conditional Formatting that you applied that is causing it to be highlighted? Or am I missing the point :confused:
 

mdlueck

Sr. Application Developer
Local time
Today, 16:14
Joined
Jun 23, 2011
Messages
2,631
You know very well that ActiveForm returns the currently active form

I found where the green background is going... It is ending up on the parent form's field rather than the child record picker form.

Off to research why I needed to code via ActiveForm in the first place and see if I can find an alternate method.

And all because I wanted to consistently default to the Title column... otherwise sometimes the arrow keys do not work, but if I arrive to the Title field, the arrows always work. :confused: That "sometimes" seems to be if the selected item in the pick list is not the top record. If it is the top record, then the arrows work. If it is NOT the top record in the list, I need to press Tab to get the arrows to work.
 

mdlueck

Sr. Application Developer
Local time
Today, 16:14
Joined
Jun 23, 2011
Messages
2,631
Off to research why I needed to code via ActiveForm in the first place and see if I can find an alternate method.

And THAT reason would be that the article suggested the code. Please accept my apologizes, vbaInet, for thinking you might have suggested that method. All I knew is that it was something I have never coded in that style before.

So this at least sets the field of the pick list form to the green color.

Code:
  'Force the the UI to the title field control
  MePointer.fldtitle.SetFocus
  'Hack to force the colored current selection bar color upon the control we arrived at
  MePointer.fldtitle.BackColor = MePointer.fldCurrentID.BackColor
Now to see if I can prevent the green going to the wrong form. hhhhmmmm... Perhaps try to use MePointer instead of ActiveForm... hhhmmm...
 

mdlueck

Sr. Application Developer
Local time
Today, 16:14
Joined
Jun 23, 2011
Messages
2,631
The solution indeed was to use the pointer I had already received an not reference the Screen object:

Code:
'Generic API used for the colored row selection capability
Sub uiutils_GridSetSelectedRowBackgrond(ByRef MePointer As Form)
  On Error Resume Next

  MePointer.ActiveControl.BackColor = MePointer.fldCurrentID.BackColor

End Sub
And I was able to remove the LOC I posted above and labeled "Hack".

fffeeewww... All's well that end's well!!! :D
 

Users who are viewing this thread

Top Bottom