Default from previous record

Chris Watson

Registered User.
Local time
Today, 20:15
Joined
Jan 23, 2004
Messages
21
Hi
Im wanting to set a default text from a previous record.
I have a fields that has Start location and Finish location,
Im wanting to set a defaulf so that the Finish location from the previous record is defaulted to the Start location of the next.
Is this possible????
Please help.
 
Yes, it is. In the form's AfterUpdate event, set the default value for the control.

example:
Code:
    Me.YourFinishLocationTextBoxName.DefaultValue = Chr(34) & Me.YourStartingTextBoxName & Chr(34)
 
Please note that Bob's solution is valid only in forms - because it relies on code and the fact that the form's previous data might still be available.

In a table or query datasheet view, there is no code to be able to reach those fields and there is no such thing as a "NEXT" or "PREVIOUS" reference in those views. Has to do with the nature and origins of the SQL that underlies data retrieval.

The only reason it works for forms is because the forms impose a secondary structure that is not present in the datasheet view of a table or query.

Having said that, Bob didn't steer you wrong. Just don't assume there's an easier way to do what you want. There isn't.
 
Thanks Doc, I got to this post through the New Posts link and didn't notice it was posted in the Tables forum. I keep forgetting to look at that :D before answering.
 
Yup, that catches me now and then, too.
 
Hi Bob
Ive tried the code but I get an error message "Dose not contain the Automation object ME"
am I doing something wrong.
Regards
 
ME is valid only in the VBA of a class module (associated with the form in question). Outside of the form's class module, ME has no meaning unless you declare it. It is a situational shortcut for {the form associated with the class module in which this code is running}. Which is why they chose something shorter to type ... ME.
 
Sorted

Hi Bob
Sorry in the delay to get back to you but I work away from home and get onto the net at weekends. Anyway I was putting the code in the Expression builder of the After Events and not the code builder, Its working fine now but I do have another question that has been bugging me, The data base Im trying to construct is a HGV Drivers time sheet that has laws on working time, I need to show 17 week periods of work, ie I would like it to show "Week 1" on the form and "Week 2" on the next record up to week 17 then start again is this possible.
Thanks again Bob your a star.
Chris
 

Users who are viewing this thread

Back
Top Bottom