Results 1 to 8 of 8
  1. #1
    joe5 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2018
    Posts
    6

    Subform conditional formatting disappear after textbox change event

    Dear all,

    I have a main form called "frmMain" that contains 3 items:
    1. text box named "tbxDate", that has a datepicker in it
    2. button named "btnClear"
    3. tabular subform called "sFrm" showing 2 fields (id, purDate)


    The subform "sFrm" has a conditional formatting on ita records.

    When i choose a date from the datepicker in the text box "tbxDate", the event tbxDate_change occur and filters the subform on its "purDate" field and the conditional formatting disappear. But when click a left click with ny mouse anywhere on the main form "frmMain" the conditional formatting will show again... !!



    Any idea how to solve this ??

    Thank you

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Try setting the focus to a control on the subform after selecting a date e.g.
    Code:
    Me.sfrm.Form.purDate.SetFocus
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    joe5 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2018
    Posts
    6
    Quote Originally Posted by ridders52 View Post
    Try setting the focus to a control on the subform after selecting a date e.g.
    Code:
    Me.sfrm.Form.purDate.SetFocus
    I tried to but still not working, i even tried to setfocus on the button "btnClear" that is on thr main form "frmMain" but still not showing. it is only working when i click a left click with my mouse on anywhere on the main form "frmMain" it does like a refresh or something and the conditional formatting re-appear on the subform.

    Though i tried the "me.refresh" and the "me.requery" but still nothing.

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    The focus needs to be on the subform. Do you have a subform command button you could set the focus to?
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    joe5 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2018
    Posts
    6
    Quote Originally Posted by ridders52 View Post
    The focus needs to be on the subform. Do you have a subform command button you could set the focus to?
    I just added a button on the subform and named it "btnTrial".

    But still nothing.... here is the code:

    Code:
    Private Sub tbxDate_Change()
         'i do my filter here
         With Me.sFrm.Form
              .FilterOn = False
              .Filter = "[purDate] = " & Me.tbxDate.Value & ";"
              .FilterOn = True
         End With
         ' and here i added the setfocus
         Me.sFrm.Form.btnTrial.SetFocus
    End Sub

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Quote Originally Posted by joe5 View Post
    I just added a button on the subform and named it "btnTrial".

    But still nothing.... here is the code:

    Code:
    Private Sub tbxDate_Change()
         'i do my filter here
         With Me.sFrm.Form
              .FilterOn = False
              .Filter = "[purDate] = " & Me.tbxDate.Value & ";"
              .FilterOn = True
         End With
         ' and here i added the setfocus
         Me.sFrm.Form.btnTrial.SetFocus
    End Sub
    As its a date field, you need date delimiters
    Code:
    .Filter = "[purDate] = #" & Me.tbxDate.Value & "#;"
    Have you checked it is setting the focus as you would expect?
    If not, you may have a different CONTROL name for your subform. Use that.
    You could also try adding a DoEvents line before the set focus line though I doubt that will solve it
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    joe5 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2018
    Posts
    6
    Quote Originally Posted by ridders52 View Post
    As its a date field, you need date delimiters
    Code:
    .Filter = "[purDate] = #" & Me.tbxDate.Value & "#;"
    Have you checked it is setting the focus as you would expect?
    If not, you may have a different CONTROL name for your subform. Use that.
    You could also try adding a DoEvents line before the set focus line though I doubt that will solve it
    I am sorry i was typing the code on my mobile i didnt pay attention for the # for the date filter...

    Yes i am sure about the control name and still nothing working !!!

    I really have no idea :s !!!

  8. #8
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Nor me. Perhaps try and prevent the CF disappearing in the first place.
    I have a better date picker than the built in version that is very easy to use.
    It may solve the problem
    https://www.access-programmers.co.uk...d.php?t=298062
    It's a nifty little utility even if it doesn't help.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. subform change to textbox or combobox
    By lladnek in forum Access
    Replies: 3
    Last Post: 11-14-2016, 05:22 AM
  2. Replies: 3
    Last Post: 10-22-2015, 07:15 AM
  3. Replies: 2
    Last Post: 12-07-2014, 01:15 PM
  4. Condition Formatting at After Update event (TextBox)
    By excellenthelp in forum Programming
    Replies: 8
    Last Post: 06-20-2014, 02:54 PM
  5. Replies: 18
    Last Post: 09-30-2011, 06:41 AM

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