Is there a way to set the default value of a field to the previous record's value?
So, if I have:
Start Stop
1 2
2 3
3 4
etc... I want to pull the Start from the previous Stop so I don't have to enter the same thing twice.
Is there a way to set the default value of a field to the previous record's value?
So, if I have:
Start Stop
1 2
2 3
3 4
etc... I want to pull the Start from the previous Stop so I don't have to enter the same thing twice.
I'm not trying to set the value to the same field value from the previous record, I'm trying to set it to a different field's value in the previous record. I'm having a hard time understand that code and similar codes I've found while researching my question. Unfortunately I'm not very good with VBA.
So, I know how to get into VBA but which event am I adding the code to and on which control? Is it on the form or the text box? I am very confused. Any assistance will be greatly appreciated.
I know this shouldn't be difficult but I just don't know where to begin. Isn't there anyone who can point me in the right direction?
You can set any field:
me!Control.DefaultValue = cQuote & me!SomeOtherControl.Value & cQuote
I've tested it in either the before or after update event of the control, can't remember which offhand.
Thank you. I'm gonna try that and see what happens
My controls are named txtStartTime & txtEndTime. I tried putting the code below in both the before and after update events of the txtStartTime control and I got nothing.
const cQuote="""" 'Thats two quotes
me!txtStartTime.DefaultValue = cQuote & me!txtEndTime.Value & cQuote
I am so clueless on this.
Since it's dependent on the end time, I'd use the update event of end time so that when it changes your value changes.
WAHOOO!!!! That was it! thank you so much! I'm extactic.
Happy to help!
Uh Oh! I have an error in my logic because of the way I do data entry. So I'll need to modify this somehow so that if I update the EndTime of a record that update will go to the StartTime of the next record not just of the new record.
Let me see if I can explain this.
So... when I do data entry it is faster/easier for me to go down than across using the enter key. If my data looks like this for example:
Activity| StartTime| End Time|
100 | 0600| 0700|
101 | 0700| 0800|
102 | 0800| 0900|
I'll type all the activities first then the first StartTime, then the EndTimes. So, the records are already created which means my code doesn't work in the way that I have it because it's only update new records.
So, what do I need to do so that I actually am updating pre-existing records. I saw a post on here that started to address this I think but there was no solution.
https://www.accessforums.net/access/...ata-11171.html
I'd want my code to work out this way regardless of how I do data entry anyway, because there are times when I need to change an EndTime and I would want that to automatically update the corresponding StartTime.
wrong thread
Sorry, I lost track of this thread. If you have some order of records that can be relied upon, it wouldn't be hard to open a recordset and get the next record, so when you change the end time field it will update the next start time. The key is to be able to identify that next record.