Solved

Changing date field color within query - Access/VBA

Posted on 2012-03-15
6
239 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
  • 3
  • 3
6 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 1

Author Comment

by:drivers
Comment Utility
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
Comment Utility
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
Comment Utility
ok..thanks for your help anyway
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now