Force a form control to a value after form exited?

  • Thread starter Thread starter David
  • Start date Start date
D

David

I have to modify a very complex database.
Currently a form allows a begin and end date to be
selected for reporting.
In every report this system handles this is no problem.
In the new report I'm writing the begin and end dates MUST
span exactly 8 weeks. There is NO error processing on the
report parameter screen since everything is selectd from
listboxes.
So, I'm allowing entry of the END DATE only and
calculating back to force the starting date.
HOWEVER, the report queries all refer to the dates via
functions BeginDate() and EndDate() which refer directly
to the form values. How do I force this value to be my 8-
week span? I have to set the Begin Date based on the End
Date in the form control after the form has been processed.
Is this possible ?? The form control for the Begin Date
has ENABLED set to FALSE to prevent data entry.
I'm no Access wizard and I'm using Access 2K.
 
Put code similar to this on the AfterUpdate event of the END DATE control:

Private Sub ENDDATE_AfterUpdate()
Me.STARTDATE.Value = DateAdd("ww", -8, Me.ENDDATE.Value)
End Sub

Be sure to substitute the correct names of the controls for ENDDATE and
STARTDATE.
 
Ok, I tried this but there are a few problems.
If the user allows the End Date control to retain its
default value, the After Update event does not get
triggered and the Start Date is not set. Also I'd like the
user to see the Start Date appear immediately after the
End Date is entered. Is there another event I could use?
- David
 
Put a command button on the form and use its Click event to run the query.
Always better to do this anyway so that the user doesn't mistakenly run a
query after entering a wrong "end date" value.
 
Yes.

--
Ken Snell
<MS ACCESS MVP>

David said:
So this will work even if the startdate control is not
enabled?
That was one of the things that was confusing me.
- David
 
Back
Top