Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can Form Field have default formula AND override?

Status
Not open for further replies.

1stTimeOut

Technical User
Mar 2, 2007
6
US
I need a field (DateB)in a form where the default date is based on two criteria:

1. A specific box (BlockA)is checked
2. A date is entered into another field (DateA)
If both 1 and 2 are true, then (DateB)=((DateA)-7).

Ocassionally, the user will need to override the formula in (DateB) and enter a specific date.

Possible? Does the code go into an event or a control source?

Thank you!!!

 
As DateB should be updatable by the user you can't set its value with a formula in the ControlSource.
In the AfterUpdate event procedures of BlockA and DateA:
If IsDate(Me!DateA) And Me!BlockA Then
Me!DateB = DateA - 7
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,
Thanks but no luck with that one. DateB doesn't populate at all now.

Anything event required in DateB?

Thanks for your time!
 
try this

setup you form for these event procedures.

Private Sub BlockA_AfterUpdate()
If Me.BlockA = True And Not IsNull(Me.DateA) Then CalcDateB
End Sub

Private Sub CalcDateB()
If Me.BlockA = True And Not IsNull(Me.DateA) Then
Me.DateB = Me.DateA - 7
End If
End Sub

Private Sub DateA_AfterUpdate()
If Me.BlockA = True And Not IsNull(Me.DateA) Then CalcDateB
End Sub
 
How are ya 1stTimeOut . . .

Are you enter the code in the [blue]event line[/blue] [surprise] or the [blue]event procedure[/blue] (click the three elipses
Elipse3.BMP
just to the right of the event line) . . .

Calvin.gif
See Ya! . . . . . .
 
Event procedure for both the After Updates

The CalcDateB is a subroutine called by the BlockA_AfterUpdate and the DateA_AfterUpdate

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top