From: John on
Hi guys,

I've ran out of condtions on the conditional format tool access
provides, so I'm now using the VB code to create another rule for my
form.

My form consists of two columns, Product and Date Entered. I need any
products to grey out after a specific date. This specific date is
01/05/08.

I've tried this code at the bottom, which I don't think is a million
miles away from working I just think the date is not being picked up
by VB and I don't know how to put dates in correctly into VB so it can
read them.

If Me.txtfDateEntered < #01/05/08# Then
Me.txtProduct.BackColor = 16777164
Me.txtProduct.ForeColor = 12632256
Else
'
End If

So what is the correct way of putting dates into VB so my code can
work? Any help is much appreciated thanks.
From: Allen Browne on
If this form shows multiple records (e.g. Continuous or Datasheet view), the
code won't work. All rows will change.

In what event are you doing this? Try the Current event of the form.

Your code looks okay. #01/05/08# will be interpreted as Jan 5 2008
(regardless of your regional settings), unless you are using Access 1 or 2.

Don't forget to handle the case the text box is Null.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"John" <david_lcfc(a)hotmail.com> wrote in message
news:b2e7aade-53d0-4b84-930d-95b726cb0fca(a)a15g2000yqm.googlegroups.com...
> Hi guys,
>
> I've ran out of condtions on the conditional format tool access
> provides, so I'm now using the VB code to create another rule for my
> form.
>
> My form consists of two columns, Product and Date Entered. I need any
> products to grey out after a specific date. This specific date is
> 01/05/08.
>
> I've tried this code at the bottom, which I don't think is a million
> miles away from working I just think the date is not being picked up
> by VB and I don't know how to put dates in correctly into VB so it can
> read them.
>
> If Me.txtfDateEntered < #01/05/08# Then
> Me.txtProduct.BackColor = 16777164
> Me.txtProduct.ForeColor = 12632256
> Else
> '
> End If
>
> So what is the correct way of putting dates into VB so my code can
> work? Any help is much appreciated thanks.

From: John on
On Jan 14, 9:21 am, "Allen Browne" <AllenBro...(a)SeeSig.invalid> wrote:
> If this form shows multiple records (e.g. Continuous or Datasheet view), the
> code won't work. All rows will change.
>
> In what event are you doing this? Try the Current event of the form.
>
> Your code looks okay. #01/05/08# will be interpreted as Jan 5 2008
> (regardless of your regional settings), unless you are using Access 1 or 2.
>
> Don't forget to handle the case the text box is Null.
>
> --
> Allen Browne - Microsoft MVP.  Perth, Western Australia
> Tips for Access users -http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "John" <david_l...(a)hotmail.com> wrote in message
>
> news:b2e7aade-53d0-4b84-930d-95b726cb0fca(a)a15g2000yqm.googlegroups.com...
>
> > Hi guys,
>
> > I've ran out of condtions on the conditional format tool access
> > provides, so I'm now using the VB code to create another rule for my
> > form.
>
> > My form consists of two columns, Product and Date Entered. I need any
> > products to grey out after a specific date. This specific date is
> > 01/05/08.
>
> > I've tried this code at the bottom, which I don't think is a million
> > miles away from working I just think the date is not being picked up
> > by VB and I don't know how to put dates in correctly into VB so it can
> > read them.
>
> > If Me.txtfDateEntered < #01/05/08# Then
> > Me.txtProduct.BackColor = 16777164
> > Me.txtProduct.ForeColor = 12632256
> > Else
> > '
> > End If
>
> > So what is the correct way of putting dates into VB so my code can
> > work? Any help is much appreciated thanks.

Yes I was using the onCurrent event with a continous form, so it
wouldn't have worked anyway. I don't quite understand then how it
works with conditional formatting and not with VB.

Many thanks for you help on the subject Allen.