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

User enters date, other dates are calculated.

Status
Not open for further replies.

donnycarr

Programmer
Oct 10, 2001
9
GB
I have created a text box on the form, formatted to Date/Time and with an Input Mask where the user inputs a certain date).

I now want to create some "boxes??" next to this with calculations to work out a date 4, 12 and 52 weeks previous to the date entered by the user. I will then get the queries to pick up these dates from the various boxes in order to select certain records.

If anyone can help it would be much appreciated, I am really struggling with this..

Thanks

...Donny
 
In the after_Update event of the date text box put something like this:

textBox1 =x DateAdd("ww", -4, txtDate)
textBox2 =x DateAdd("ww", -12, txtDate)


where txtDate is trhe name of your date field

Nick
 
You could use the datediff function. THere is a good example using this function as a query criteria in access help...

Code:
'The next example shows how to use the DateDiff function in a query expression. Suppose you have an Orders table that contains an OrderDate field and a ShippedDate field. You can create a calculated field in a query to display the time elapsed between an order date and a shipped date for each order. In the Query window, create a new query by adding the Orders table and dragging the OrderID field to the query design grid. In an empty Field cell, enter the following to create a calculated field.

DaysElapsed: DateDiff("y", [OrderDate], [ShippedDate])

You should be able to play around with this until you get something that works.

Robbo ;-)
 
Donny,

Sorry. Foe some reason i have an x there.

It should read:

textBox1 = DateAdd("ww", -4, txtDate)
textBox2 = DateAdd("ww", -12, txtDate)
textBox3 = DateAdd("ww", -52, txtDate)

where txtDate is the date field and txtBox1, 2 and 3 refer to your extra text boxes

Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top