Populate a field based on another field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Access 2002, Windows 2000

I need help with VBA code for the following:

If field "fldDay" equals "01" or "1", populate field "fldOverride" with an
"N", otherwise populate field "fldOverride" with a "Y".

Field "fldOverride" needs to be editable only by this formula, and not by
hand.

Can you help?

Thank you,

Allison
 
Hi Allison,

I tried this using the OnLostFocus event and it seemed to
work. Don't know if it will work on another event:

If fldDay = "01" Or "1" then
 
Hi Allison,

I tried this using the OnLostFocus event and it seemed to
work. Don't know if it will work on another event:

If fldDay = "01" Or "1" then
 
Oops, somehow my message got sent before I was done:

If fldDay = "01" or "1" then
fldOverride = "N"
Else fldOverride = "Y"
End If

You can then set the tab stop property to the
fldOverride field so that the cursor does not go there.

Hope that helps.
Patti
 
Thanks Patti. I was just going to write back and say never mind I found the
answer.

This is what I found elsewhere:

Private Sub fldDay_AfterUpdate()
If Me.fldDay = 1 Then
Me.fldOverride = "N"
Else
Me.fldOverride = "Y"
End If

End Sub

Then I selected the fldOverride code and changed it's lock property to "Yes"
and that worked.

Thanks for all the help.
 
Back
Top