Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Changing date field color within query - Access/VBA

Posted on 2012-03-15
6
Medium Priority
?
263 Views
Last Modified: 2012-03-21
Hi Experts

I have following condition for which i would like to have fields highlited with colors when query results being viewed in Datasheet view.

1 = Red
2 = Yellow

IIf(([DATEDUE]<Date()),1,IIf([DATEDUE]>Date() And [DATEDUE]<DateAdd("d",+30,Date()),2))

Thanks
0
Comment
Question by:drivers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 2000 total points
ID: 37728214
You can't do that in a query datasheet.

You need to build a form from your query and you can then use Conditional Formatting  (from the format menu) for the field. The default view for your form can be set as datasheet in the form properties.
0
 
LVL 1

Author Comment

by:drivers
ID: 37736214
Hi

Thanks for suggestion, due to nature of this dynamic query its lot of overhead for me. It is actually being exported to excel and was hoping that formatting show up in excel too..

There is a suggestion somwhere to use field Format property within QBE using 0[Black];0[Red];0[Black], however trying to use with logic (two colors as stated above) but can't seems to figure out.

Any ideas?

Thanks
0
 
LVL 77

Expert Comment

by:peter57r
ID: 37736683
The field formats represent     positives ; negatives; zero   so you can't use the feature to distinguish between positive values.

( Although if it could be used, then  the formatting would carry over to Excel on an export.)

I'm afraid I can't see a solution for you using the query datasheet.
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 1

Author Comment

by:drivers
ID: 37740601
well i guess i have to take that as last resort, but before i am wondering is it possible if i can call this from creating a function? if it is then can you give me high level example

some thing like this

if queries!testquery!Datedueflag = 1 then
   queries!testquery!Datedueflag.backcolor(or fontcolor) = vbred
   elseif ......
endif


Thanks
0
 
LVL 77

Expert Comment

by:peter57r
ID: 37741137
In a continuous form or datasheet , the only way to get different colours in different records is to use conditional formatting.

If you use code, then the colour that is appropriate to the current record is applied to all visible records.
0
 
LVL 1

Author Comment

by:drivers
ID: 37746442
ok..thanks for your help anyway
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question