Automatically format

B

burnspaul

Hi, I want to enter a date into 1 field (a) and change font and colour
in another field (b) but still retain the data that is in field b. Can
you help. Thanks
 
A

Arvin Meyer [MVP]

Use the AfterUpdate event to change the font and color. Something like:

Sub txtControlA_AfterUpdate()
If Len(Me.txtControlA & vbNullString) > 0 Then
Me.txtControlB.FontBold = True
Me.txtControlB.ForeColor = vbRed
Else
Me.txtControlB.FontBold = False
Me.txtControlB.ForeColor = vbBlack
End If
End If
 
B

burnspaul

Use the AfterUpdate event to change the font and color. Something like:

Sub txtControlA_AfterUpdate()
    If Len(Me.txtControlA & vbNullString) > 0 Then
        Me.txtControlB.FontBold = True
        Me.txtControlB.ForeColor = vbRed
    Else
        Me.txtControlB.FontBold = False
        Me.txtControlB.ForeColor = vbBlack
    End If
End If
--
Arvin Meyer, MCP, MVPhttp://www.datastrat.comhttp://www.mvps.org/accesshttp://www.accessmvp.com






- Show quoted text -

Sorry for being stupid but can't get this towork. Field 1 is called
Date, Field 2 is called Days, I would like to thank you for your help
 
A

Arvin Meyer [MVP]

I see why, the last End If should be End Sub, but you have another problem.
Date is a reserved word and should never be used as a field or control name.
I'll change it to try and make it work for you:

Sub DateField_AfterUpdate()
If Len(Me.DateField & vbNullString) > 0 Then
Me.Days.FontBold = True
Me.Days.ForeColor = vbRed
Else
Me.Days.FontBold = False
Me.Days.ForeColor = vbBlack
End If
End Sub
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Use the AfterUpdate event to change the font and color. Something like:

Sub txtControlA_AfterUpdate()
If Len(Me.txtControlA & vbNullString) > 0 Then
Me.txtControlB.FontBold = True
Me.txtControlB.ForeColor = vbRed
Else
Me.txtControlB.FontBold = False
Me.txtControlB.ForeColor = vbBlack
End If
End If
--
Arvin Meyer, MCP,
MVPhttp://www.datastrat.comhttp://www.mvps.org/accesshttp://www.accessmvp.com






- Show quoted text -

Sorry for being stupid but can't get this towork. Field 1 is called
Date, Field 2 is called Days, I would like to thank you for your help
 
B

burnspaul

I see why, the last End If should be End Sub, but you have another problem..
Date is a reserved word and should never be used as a field or control name.
I'll change it to try and make it work for you:

Sub DateField_AfterUpdate()
    If Len(Me.DateField & vbNullString) > 0 Then
        Me.Days.FontBold = True
        Me.Days.ForeColor = vbRed
    Else
        Me.Days.FontBold = False
        Me.Days.ForeColor = vbBlack
    End If
End Sub
--
Arvin Meyer, MCP, MVPhttp://www.datastrat.comhttp://www.mvps.org/accesshttp://www.accessmvp.com







Sorry for being stupid but can't get this towork. Field 1 is called
Date, Field 2 is called Days, I would like to thank you for your help- Hide quoted text -

- Show quoted text -

Thank you - works great, have also changed field name from date to
date received. Thanks
 
A

Arvin Meyer [MVP]

One other tip: When possible, do no leave spaces in field names, If you do,
you'll always need to use square brackets around your field or control names
in code or SQL. Most database programmers either use an underscore or Camel
case, So instead of:

Date Received

use:

Date_Received

or:

DateReceived

I prefer Camel case because it's more intuitive to me, and I think it's more
readable.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

I see why, the last End If should be End Sub, but you have another
problem.
Date is a reserved word and should never be used as a field or control
name.
I'll change it to try and make it work for you:

Sub DateField_AfterUpdate()
If Len(Me.DateField & vbNullString) > 0 Then
Me.Days.FontBold = True
Me.Days.ForeColor = vbRed
Else
Me.Days.FontBold = False
Me.Days.ForeColor = vbBlack
End If
End Sub
--
Arvin Meyer, MCP,
MVPhttp://www.datastrat.comhttp://www.mvps.org/accesshttp://www.accessmvp.com







Sorry for being stupid but can't get this towork. Field 1 is called
Date, Field 2 is called Days, I would like to thank you for your help-
Hide quoted text -

- Show quoted text -

Thank you - works great, have also changed field name from date to
date received. Thanks
 
Top