Two Date Fields

A

aubrey

Hi ,

I have two fields, "Close Date" and "Distribution Date."

I would like to have Closed Date default, to whatever date is in
Distribution Date, if there is a date in Distribution Date, but if there is
no date in Distribution Date, I would like to be able to manually enter a
date in the Close Date field.

I currently have an express in the Close Date field:
-ClosedDate: IIf([DistributionDate] Is Not Null,[DistributionDate])
This expression works to auto fill the Closed Date field if Distribution
Date is filled in but, it will not allow me to enter a date in Closed Date if
there is nothing in the Distribution Date.

I also tried:ClosedDate=DistributionDate, but this auto fills one filed if
data is in the other. The problem is that it is possible to have a Close Date
w/o a Distribution Date, but if there is a Distribution Date the Closed Date
will be the same.

Any help with this would be greatly appreciated,
 
J

John Spencer

Assuming that you are using a form for data entry, then use VBA code in
the After Update event of the control bound to the Distribution Date
field to set a value into the control bound to the Close Date field.
Assuming the controls are named txtDistributionDate and txtCloseDate the
VBA would look like.

Private Sub txtDistribution_AfterUpDate()

If IsDate(Me.txtDistributionDate) Then
If IsNull(Me.txtCloseDate) = True Then
Me.txtCloseDate=Me.txtDistributionDate
End If
End IF

End Sub


'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
A

aubrey

Thanks,

I knew I was over thinking it.

John Spencer said:
Assuming that you are using a form for data entry, then use VBA code in
the After Update event of the control bound to the Distribution Date
field to set a value into the control bound to the Close Date field.
Assuming the controls are named txtDistributionDate and txtCloseDate the
VBA would look like.

Private Sub txtDistribution_AfterUpDate()

If IsDate(Me.txtDistributionDate) Then
If IsNull(Me.txtCloseDate) = True Then
Me.txtCloseDate=Me.txtDistributionDate
End If
End IF

End Sub


'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================

Hi ,

I have two fields, "Close Date" and "Distribution Date."

I would like to have Closed Date default, to whatever date is in
Distribution Date, if there is a date in Distribution Date, but if there is
no date in Distribution Date, I would like to be able to manually enter a
date in the Close Date field.

I currently have an express in the Close Date field:
-ClosedDate: IIf([DistributionDate] Is Not Null,[DistributionDate])
This expression works to auto fill the Closed Date field if Distribution
Date is filled in but, it will not allow me to enter a date in Closed Date if
there is nothing in the Distribution Date.

I also tried:ClosedDate=DistributionDate, but this auto fills one filed if
data is in the other. The problem is that it is possible to have a Close Date
w/o a Distribution Date, but if there is a Distribution Date the Closed Date
will be the same.

Any help with this would be greatly appreciated,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top