Expression Builder

  • Thread starter Thread starter lfry
  • Start date Start date
L

lfry

Guest
I am creating a sales logging database and haven't used Access in a few years - my mind is boggling!!!

I've got a Main table which has a date field called 'Date Received' to log the received item date and I want to create an automatic date field called 'Respond By' 14 days after this date to show people what their response time is.

Problem is, when I select the Default Value and go into the Expression Builder for the automatic 'Respond By' date, the Expression elements on offer are only Functions, Constants and Operators and it won't give me my 'Main' table to refer back to to build an Expression which is Date Received +14.

I can build this expression into the form but it won't log the information back in the Main table???

How can I get around this?
 
Suggestion, don't give the Respond By field a default value. The data in this field should be generated whenever the Date Received field is changed.

I'll assume you are using a form to update/change the Date Received field. Assign code to the AfterUpdate event on the Date Received field.

The AfterUpdate event would run code that makes

Respond Date = Recieved Date + 14.

You would probably use the DateAdd function.

Good Luck
 
Code:
DateAdd("d", 14, Me.[Date Received])

d; specifies that we are adding days
14; number of days we are adding
Me.[Date Recieved]; date we are adding to
________
AMC SPIRIT SPECIFICATIONS
 
Last edited:
Code:
    Dim addDays As Date
    addDays = DateAdd("d", 14, Me.txtDate)
    
    Me.txt14Days = addDays

Me.txtDate; Date that is currently displayed
Me.txt14Days; The date in Me.txtDate + 14 days
________
Ford Telstar
 
Last edited:
Variant view:

If the field's value is invariant at 14 days, why store it? Just always compute it when you need it based on the thing you DID store.

Unless there are cases where the answer ISN'T 14 days because the particular item requires someone in Tibet to shear a yak and weave the fur.

But default values aren't the way to go anyway. Instead, add some code to your form so that when the [Date Received] field changes, you store a new value in the [Respond By] field. This is a Forms Event/VBA type solution.
 
What you suggested The_Doc_Man is already what he wants, he knows he wants to add 14 days to a unbound field, thats why he was trying to use the expression builder. :)
________
CODEINE REHAB FORUMS
 
Last edited:

Users who are viewing this thread

Back
Top Bottom