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

Populate table with new records based on first value entered. VBA Access

P: 17
Hi,

I'm very new to writing databases using VBA and I'm sure this is relatively simple to solve.

I have a table called tblYear and the user enters a value of a year from a form e.g. 2003. I would then like the table to populate with the years for the next 5, each with a new user I.D. on button press for example.

e.g.
ID Year
1 2003
2 2004
3 2005
4 2006
5 2007

I'm guessing with a for loop stepping through values of i, but I simply don't know how to write this.

Any help would be GREATLY appreciated.

Zoe
Jul 27 '08 #1
Share this Question
Share on Google+
1 Reply


nico5038
Expert 2.5K+
P: 3,072
Not sure what you mean with the userid and the ID of the tblYear.
For inserting data you can use code like:
Expand|Select|Wrap|Line Numbers
  1. Dim intI as Integer
  2. for intI = 0 to 4
  3.    currentdb.execute("INSERT INTO tblYear (Year) VALUES(" & Me.txtYear + intI & ")")
  4. next
  5.  
Nic;o)
Jul 27 '08 #2

Post your reply

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