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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

when form opend ,perform the check with the date for unbound filed

Status
Not open for further replies.

noorani

Programmer
Dec 11, 2002
46
0
0
FR
in my form i have 2 bound fields OrderDate (Date Field) , and the reserved days (Integer field). now i want to make an unbound field where i can perform the check and show the remaining reserved days , comparing with the current date and reserved days. here is the example for better understanding.

suppose i have Add this record on 19-Mar-03

Orderdate : 19-Mar-03 (bound field)
Reserved days: 12 (bound field)
Remaining Reserved Days: 12 (Calculated unbound field)


if i open this record on 19-Mar-03 then the data on form should look like this.


Orderdate : 19-Mar-03
Reserved days: 12
Remaining Reserved Days: 12

If i open this record on 20-Mar-03 then the data on form should like this.

Orderdate : 19-Mar-03
Reserved days: 12
Remaining Reserved Days: 11


and if i open this record on 02-Apr-03 then the data on form should look like.

Orderdate : 19-Mar-03
Reserved days: 12
Remaining Reserved Days: 0

and the remaining reserved days field will remain 0 if the current date cross the reserved days.

i have tried setting the default value equal to ,

=Days-[OrderDate]-[Remaining Reseved Days]

but i guess that it's not a good approach.

Please advise me how can i perform check like this..

Thanks in advance.
 
Hi Noorani

Set the Control Source for your unbound control to:

=([orderdate]+[reserveddays])-Date()

HTH

Chris
 
thank that's great but what if the difference of the current date will be greater then the Reserved days, then this formula will show the negative value ,and i want to show the 0 if the difference of the current date increase the reserved days. means that i should perform some kind of check that if this formula gives the negative value then show 0 in the unbound field.

any idea,
 
Hi friends i have solved my task by doing the following.

i have declare the variable in the "On Current" event of my form, and perform the check. here is the code.

note: tmleft is the variable to hold the value which i have declare in my "On Current" event.



tmleft = ([OrderDate] + Nz([Text217], 0)) - date
If Me.reservecheck = True Then
Me.Label223.Visible = True
Me.findclock.Visible = True
Me.Label224.Visible = True
If tmleft <= 0 Then
Me.findclock = 0
Else
Me.findclock = tmleft
End If
End If


thanks.
 
Or you could perform the check on the unbound field, by setting the control source to:

=IIf(([orderdate]+[reserveddays])-Date()<0,0,([orderdate]+[reserveddays])-Date())

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top