Results 1 to 7 of 7
  1. #1
    guest is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2024
    Posts
    61

    conditional formatting

    Hi,


    i am trying conditional formatting for a filed. i consider if my form contain same [ОсновенБрој] field and [Подброеви] field second record is duplicate. i tried this exppression: DCount("*";"Delovodnik";"[ОсновенБрој] = " & [ОсновенБрој] & " AND [Подброеви] = " & [Подброеви] & " AND [DelovodnikID] < " & [DelovodnikID])>0 on testform and worked. however on original dont. [ОсновенБрој] field and [Подброеви] field are both numbers. [ОсновенБрој] field is never null. [Подброеви] field can be null but records with null are not considered duplicates. i doubt null values in filed [Подброеви] make expression not to work. with this expression all records are red not just duplicates. By the way expression is in the field [Подброеви].

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,560
    Put your code within code tags please.
    I am finding it really hard to read any of that garble you posted.?

    For a start you ned to harcode the field and it's comparable value.?

    What you posted does not appear to do that?

    When you have any criteria more than one, the put it all into a string variable.

    Debug that string until you get it correct.
    Only then use it in the functions.

    Plus I always use Me. to indicate I am referring to the form control NOT the field?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    guest is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2024
    Posts
    61
    i don't have code. it is just above expression for conditional formatting in the filed [Подброеви].
    again expression is:
    DCount("*";"Delovodnik";"[ОсновенБрој] = " & [ОсновенБрој] & " AND [Подброеви] = " & [Подброеви] & " AND [DelovodnikID] < " & [DelovodnikID])>0

    when i used this expression in test database with few records and no null values in the field [Подброеви] second record with same [ОсновенБрој] and same [Подброеви] filed turn second record filed [Подброеви] to red only that record and that field. when i tried it in full version where field [Подброеви] has value null too all records in the fields [Подброеви] turn red what is not what i want.
    here how it looks nowClick image for larger version. 

Name:	Untitled.jpg 
Views:	21 
Size:	113.5 KB 
ID:	53073

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Welsh, this expression is in a Conditional Formatting rule, not VBA. And no, I don't think hard-coding comparison value is called for here.

    guest, you are spelling "filed" which should be "field".
    I tested your expression and it works for me.
    Records with Null in field are not counted and records highlight appropriately.
    Would have to examine your data. Provide sample table (copy/paste or use table builder on post Advanced editor). Or provide db. The language barrier will be a challenge but might be able to identify issue.
    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
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,560
    Put the criteria into a string variable and debug.print it in the Current event.
    You can easily get
    Code:
    AND [Подброеви] = Null
    though why it would affect all records is beyond me.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    guest is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2024
    Posts
    61
    Sorry June I can not send you the database contain confidential data and without data it has no point. but after checking again and again here is what I noticed. database contain data from year 2017 to 2025. for testing i deleted previous years and tested only with full year 2025 (null and everything) and it works. so what this mean and where should i look and search for what.

  7. #7
    guest is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2024
    Posts
    61
    I fix it. it should check for only one year not for all years. Thank you all for help.

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

Similar Threads

  1. Replies: 2
    Last Post: 11-12-2015, 10:46 AM
  2. Conditional Query with conditional results
    By Jeff_in_KCMO in forum Queries
    Replies: 4
    Last Post: 09-10-2014, 01:44 PM
  3. Replies: 6
    Last Post: 05-26-2013, 09:10 PM
  4. Conditional Formatting vs. VBA Formatting
    By gopherking in forum Reports
    Replies: 5
    Last Post: 11-09-2011, 06:53 PM
  5. Conditional formatting
    By ylivne in forum Reports
    Replies: 1
    Last Post: 07-12-2009, 06:18 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