Google Answers Logo
View Question
 
Q: Carry value forward in Access ( No Answer,   1 Comment )
Question  
Subject: Carry value forward in Access
Category: Computers > Programming
Asked by: accessnovice-ga
List Price: $10.00
Posted: 10 Aug 2005 15:05 PDT
Expires: 09 Sep 2005 15:05 PDT
Question ID: 554178
I need code for Access to have a continuous form with default data for
a field be taken from the previous field.
This is for a date field, so what it needs to do is find the previous
date entered in that form, and set the default to the new record to
that date plus one.
(The reason I want it to simply set the default is that I want it to
be possible for the user to change this date. Not all dates should
exist, but to make things quickly, it's faster to have it default to
the previous date entered than to have to enter it every time.

I've found this code online, which is meant to do something similar to
this, but I don't know how to adapt it to make it work on my database
(changing it to make the default be previous + 1 should be trivial).
http://www.tek-tips.com/faqs.cfm?fid=4852
------------------------------------------
In summary, this is the code from that posting that I need to know how to adapt:

'For individual controls
Private Sub Form_AfterUpdate()
    'Setup error handling
    On Error GoTo Form_AfterUpdate_Err
    
    'Carry the batch number forward
     Me.Controls("controlname").DefaultValue = """" &
Me.Controls("controlname").Value & """"
       
Form_AfterUpdate_Exit:
    Exit Sub
Form_AfterUpdate_Err:
    'Alert the user that an error has occurred
    Call ErrorHandler(Err.Number, Err.Description, "frmACCT.Form_AfterUpdate")
    
    Resume Form_AfterUpdate_Exit
    
End Sub
---------------------------------------------------

Thanks,
Munir
Answer  
There is no answer at this time.

Comments  
Subject: Re: Carry value forward in Access
From: rassler2-ga on 12 Aug 2005 04:32 PDT
 
Keeping a value from a form to use in the next wouldn't be a problem.
You just pass the value back to the parent form, then the next record
form first checks the parent to see if there is a value to be entered
into that date field, if not use another means to determin the first
value to use eg now().

The problem is in multi-user databases. Do you intend each person's
date be incremented by the value '1', or is that a global thing such
that the date can only exist the once in your data?

In that case a query to find the max(date) for what ever criteria the
records are chosen would be more certain than storing a value in a
variable to use later. After all, later could be a very long time. All
it would take is for a PC to be left on over night and your system is
now wrong by one day.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy