By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,480 Members | 2,192 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,480 IT Pros & Developers. It's quick & easy.

Adding one value to the value entered in the previous record

P: 1
Hi,

I have a form that includes a subform with Days and SampleDates. I would like to know how to make access automatically populate the next record (in the subform) with the next day (i.e., Days + 1) and next day's date (i.e., SampleDate + 1). I don't know much about VBA and need some help. When a new Form record is created, the first record of the subform will have to be manually entered but I want all the subsequent Days and SampleDates for that Form's subform to be auto filled by one day/date. Any suggestions? I am a very BASIC Access user...
Jan 5 '17 #1

✓ answered by NeoPa

Your experience so far may be basic, but the question really isn't.

You need to ensure that the .DefaultValue property of the control on the form that shows this date is set, and set again where necessary, to match what is required.

The .DefaultValue property is a string value that is enterpreted when used. IE. Not always as simple as putting a few figures in there.

The code to set the value needs to be able to enquire from your database, or even of the current form itself, what the current maximum date is and if it even has one. This needs to be incremented and set as the .DefaultValue property (in the correct format of course).

I suggest you look into this, with these notes to guide you, and come back with your solution. I'm sure we can work from there if it isn't perfect first time.

Share this Question
Share on Google+
3 Replies


NeoPa
Expert Mod 15k+
P: 31,186
Your experience so far may be basic, but the question really isn't.

You need to ensure that the .DefaultValue property of the control on the form that shows this date is set, and set again where necessary, to match what is required.

The .DefaultValue property is a string value that is enterpreted when used. IE. Not always as simple as putting a few figures in there.

The code to set the value needs to be able to enquire from your database, or even of the current form itself, what the current maximum date is and if it even has one. This needs to be incremented and set as the .DefaultValue property (in the correct format of course).

I suggest you look into this, with these notes to guide you, and come back with your solution. I'm sure we can work from there if it isn't perfect first time.
Jan 5 '17 #2

PhilOfWalton
Expert 100+
P: 1,430

NeoPa
Expert Mod 15k+
P: 31,186
This thread (Item Numbering Within a Group) may be worth reading. The requirement isn't exactly the same but it certainly has strong similarities.

PS. Phil's linked answer is also well worth looking at.
Jan 5 '17 #4

Post your reply

Sign in to post your reply or Sign up for a free account.