highlight a day if it is the current day

Damob9K

Trainee numpty
Local time
Today, 14:18
Joined
Apr 12, 2014
Messages
69
Hello all,

How would I go about writing some code to highlight the current day if a day field in a form matches.

i.e. I have a schedule form that has a field that has the day manually entered, so Monday, Tuesday etc.
And on the top of the form I have a text box set to =Now() and the date format set to dd mmmm - dddd

And what I want to do is make it so what ever the current day is, any records in the form that match the current day will be highlighted.

I really don't have a clue on how to tackle this, but suspect there may be a relatively easy way of doing it if I knew what I was doing !

Any help would be greatly appreciated.

Damob
 
What do you mean by highlighted? Change Color,SetFocus?
 
I hadn't decided on that yet !! but either by changing the background colour of the cell or the text colour to red or yellow.

D
 
Since you don't know all of the details, we don't know either!
However;
If Me.SomeTextBox = Date Then
Me.SomeTextBox..BackColor = vbRed
Else
Me.SomeTextBox.BackColor = vbWhite
End If

HTH

Good Luck.
 
... or depending on how and where you're using it, could you use Conditional Formatting?
 
OK Thanks guys for putting me on the right path...

I've not played with conditional formatting as yes, so giving it a go.

So far it's not working, and I think this is because the date text box on the main form is in the format of dd mmmm - dddd which is what I want to see, but the textbox of the record in the subform is just in text format as it is just a manually typed in day, not a date.

My guess is that it's not comparing like for like ?

So can I some how separate the day name from the =Now() ,dd mmmm - dddd and then compare the -dddd to that of the day name in the record of the subform ?

Thanks

Damob
 
Hi burrina, thanks for your replies.

To try and explain myself better ..

I have a form that has a textbox at the top of it set to =Now() and the format set to dd mmmm - dddd .... so this displays as : "15 May - Thursday"

I then have a weekly schedule sub-form that has a field in it that is called "DayOn" that will just have it's entry manually typed in e.g : "Monday"

So what I was trying to say in my last post was that either conditional formatting or your suggested code is comparing an actual date field with one that is actually just a text field with "Monday" in it, so therefore probably can't compare them together. Unless I am misunderstanding things !!

PS where would I put : SomeField =Format([YourDateField],"dddd") ??

Thanks again.

Damob
 
If you want the subform DayOn to show the Day from the Main form, then using the OnCurrentEvent for the subform


Me.SomeField = Format([Forms]![MainFormName]![DateFieldName], "dddd")
Me.Dirty = False


HTH
 

Users who are viewing this thread

Back
Top Bottom