Results 1 to 7 of 7
  1. #1
    tagteam is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    501

    turn unbound box green if query is not empty

    I have a report I need to run that is for US miles. If there were miles driven in Canada then I need to run a different report. I am trying to find a way to have a notification of miles in Canada.


    So I have a dropdown box to select the customer. If that customer has Canadian mileage i would like to have a unbound box or label turn green to notify the user to run the Canadian mileage report.

    I have created a query that looks at the customer records and will show all the records in Canada. I was thinking I could do an if statement that would basically say if the query is not empty then show the box as green

    here is my rough effort

    if (dcount, "q_checkformileage" > 0 Then
    Me.messagebox.backcolor = green
    else
    Me.Messagebox.backcolor = red
    end if

    I know that doesn't really work at all but it is just my rough idea.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Try

    DCount("*", "q_checkformileage")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    tagteam is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    501
    So on the after update event of my dropdown box I have

    If DCount("*", "q_CheckForCanadianMileage") > 0 Then
    Me.Canadian.BackColor = vbRed
    Else
    Me.Canadian.BackColor = vbWhite
    End If

    I don't get an error, however the label background also does not change color

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    And the query returns records only when there are Canadian records? Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    What exactly is the name of the textbox that you want to change its background color to signify Canadian mileage involved?

  6. #6
    tagteam is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    501
    I was able to get it to work.

    Two issues I had
    1. I had to set the background color of the label box to something. It was set to transparent
    2. I had to move the code from the after update event to the on change event.

    Thanks for the help

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Glad you got it sorted out.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Export has the Green Triangles?
    By spyldbrat in forum Access
    Replies: 5
    Last Post: 04-11-2016, 07:12 AM
  2. Replies: 3
    Last Post: 10-24-2015, 04:46 AM
  3. No Green Triangle
    By antinora in forum Access
    Replies: 2
    Last Post: 05-18-2015, 09:00 AM
  4. Flash green or red
    By elmister in forum Access
    Replies: 8
    Last Post: 08-30-2011, 03:37 PM
  5. Help, I get a green thing when i put a label.
    By Starstruck00 in forum Forms
    Replies: 2
    Last Post: 06-02-2011, 10:47 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