Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    Strange behavior with Conditional Formatting


    I have a sub-form with a text box that has conditional formatting based on the setting of a Yes/No field in its RecordSource, I.e., Expression is [DetTag]=True set background of control to Red. However, the only time the formatting takes effect is when that record has the focus. As soon as that field looses the focus the formatting reverts as though [DetTag] is False. I don't know if it matters but the sub-form is a popup form which is on a main form that is also a popup.

    Thoughts?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    did you set the formatting on the textbox?
    is it an event on the textbox or the form?

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    A couple of pics below should hopefully answer your question and shed some light...................
    Click image for larger version. 

Name:	001.jpg 
Views:	43 
Size:	56.2 KB 
ID:	34702Click image for larger version. 

Name:	002.jpg 
Views:	42 
Size:	31.1 KB 
ID:	34703

    The Mouse Down Event:
    Code:
    Private Sub tbTitle_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    If Button = acRightButton Then
        RClickFrm = Me.Name           'What's our form name?
        RClickSel = Me.tbLinkID       'LinkID in tblDisplay
    End If
    
    End Sub
    "tbLinkID" is an invisible text box bound to the ID field of the record that has the focus. Both RClickFrm and RClickSel are global and are of the appropriate data types. It is the Right-Click functionality in a general module that actually updates the "DelTag" field in the current record and that update works as intended, I.e., DelTag is set to True. When the Right-Click "Action" general module ends the background color turns red also as intended but as soon as the record looses focus the background color reverts.

    I put a Me.Requery in the On Lost Focus event to see if that would have any effect but it did not.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    What code sets DelTag field?

    Are you sure the field retains True value?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Field set with this code:

    Code:
    CurrentDb.Execute "UPDATE tblDisplay SET DelTag = " & True & " WHERE LinkID = " & RClickSel
    RClickSel is the record ID of record within the RecordSource query.

    Verified by inspection of record within ControlSource
    Click image for larger version. 

Name:	003.jpg 
Views:	38 
Size:	21.9 KB 
ID:	34704

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    If code is behind form bound to tblDisplay, why elaborate code using UPDATE and global variable? Why not simply: Me!DelTag = True

    And what event is that code in?

    Might have to provide db for analysis because I am not understanding why the formatting is not working.

    Form design shows only one control. Is form really that bare?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    why elaborate code using UPDATE and global variable?
    The UPDATE statement is executed from within a general module that is responding to a right-click option selection.

    The "bare" form is a sub-form displaying a column of names from which the user may select. There are several such columns on the main form.

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    By any chance does the control with the formatting have the same name as the field it is bound to? I think not, according to the image, but not sure. This can happen if the names are the same because Access cannot distinguish between the control and the field it's bound to. I find that reports seem to respond to cf better than continuous forms do.

    I also don't get the global variable need, even after the follow up comment (which explains how it gets updated, but not why the approach is needed). I've never made a form/subform as a popup or modal either and have to wonder if that's got anything to do with it. The notion of having these forms popup style seems odd to me, and there is at least 1 form event that I know doesn't fire when it's popup & I think that's Activate. There may be others that are at play here.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    OP stated "sub-form is a popup form which is on a main form that is also a popup". The Popup property may be set to yes but if the form is installed as a subform then it is not a popup.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    I also don't get the global variable need
    Right-Click "Action" functions don't know the RecordID of the current record unless passed as a parameter to the function unless the function is within the code sheet of the form upon which it operates. All my global variables are dim'd within a general module so as to always be accessible. (There are 10 sub-forms which comprise 10 columns of names on the main form where the sub-form RecordSource(s) come from a common table filtered to blocks of records as determined by the vertical screen capacity. Access doesn't have native support for columns. I must have conditional formatting for each occurrence of the text box so a "list box" control won't get the job done.)

  11. #11
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Hi June,
    The current app is dealing with a major export of data from RoboForm and is full of security detail that would make it really difficult to provide a meaningful DB you could play with.

    The functionality I'm trying to establish is to "highlight" entries the user intends to delete while at the same time preserving the opportunity to "Undo" rather than to have the entry on the screen disappear entirely. The deletions are simply scheduled for deletion but not executed until the app closes. What's interesting to me about this caper is that the other two of the three conditional formatting specifications work perfectly. I've updated the pic below so you can see them all. Thanks for the offer to investigate the DB.

    Click image for larger version. 

Name:	004.jpg 
Views:	26 
Size:	45.7 KB 
ID:	34705

  12. #12
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    The problem is with Access. Access is not honoring the Conditional Formatting specifications. No matter what, I can't cause a change in the background color. However, Access responds to a change in the font weight and style and color BUT NOT the underscore when "[DelTag]=True".

    I don't know if it has something to do with the control being a member of a sub-form or what. I've used background color formatting on main forms many times without the problem posted here.

    Thanks to all that spent time pondering this post.
    Bill

    (PS) Always hesitant to put blame on Access for my own ignorance, I created a main form from a simple copy of the sub-form but it too won't honor a CF spec of background color change. I checked my other apps that have such CF specs and they all work as expected. Later today I'll see if I can't follow June's suggestion of posting a DB that demonstrates the failure without unnecessarily exposing confidential data.

  13. #13
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    I have no problem setting CF on subform.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    GOOD GRIEF! Would you believe the "Back Style" was marked as Transparent! What a bunch of wasted time.......... mine, yours and everyone else that looked at the thread!

  15. #15
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    Ugh, I should have thought of that since I have been tripped by the same error! Glad you figured it out.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 12-21-2016, 09:35 AM
  2. Replies: 6
    Last Post: 10-19-2016, 04:33 PM
  3. Strange TransferSpreadsheet Behavior
    By JoeM in forum Programming
    Replies: 6
    Last Post: 08-05-2015, 07:47 AM
  4. Strange Behavior on Startup
    By RonL in forum Programming
    Replies: 3
    Last Post: 02-14-2013, 03:31 PM
  5. Strange Behavior when Sorting
    By geniass in forum Queries
    Replies: 5
    Last Post: 09-02-2010, 03:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums