PDA

View Full Version : Vba Code!



dean_wat
10-31-2007, 07:13 PM
On my order form, I need to create a textbox that will display an expiration date for returning an order. The date that should be displayed in this box should be 30 days beyond the original order date listed in the form. Here is what I have so far:
Private Sub Form_Load()

Dim strDateString As String

strDateString = Docmd.FindRecord "DatePurchased" & DateAdd("d", +30, Date)

MsgBox "You have till, strDateString, to return your order."

End Sub
Can some one please help:dunno

DarkSprout
11-01-2007, 02:57 AM
OK, but what are you asking?

OTWarrior
11-01-2007, 06:25 AM
have the original date hidden (not visible) on the form, and call it's value into your textbox when the form is loaded .

dim dteExpiryDate as date
dteExpiryDate = me.txtOrderDate + 30 ' change this code to add 30 days
me.txtExpriationDate = dteExpiryDate

hope that helps

dean_wat
11-01-2007, 07:01 AM
Thank you that worked out better for me.

OTWarrior
11-01-2007, 09:50 AM
btw, if you want to use the msgbox to display how long the person has left, use:

MsgBox "You have till, " & datediff("d",date(), dteExpiryDate) & " days, to return your order."