Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create records when they do not exist

Status
Not open for further replies.

VKZIMM

Technical User
Jan 9, 2008
45
US
I am trying to create a budget type database. When they enter the Fiscal Year / Month, I would like to create a record for a group of accounts in a table so they can enter just the Budget amounts for each account. If the records exist, I would just like to display them so they can make changes. Is this possible? Example.
Table Accounts 1001 1002 1003
Form:
Fiscal year 2009
Fiscal month 01
1001 100
1002 100
1003 100
Thank you in advance
 
Yup.

db.Execute "INSERT INTO TableX (Month, Year, Account, Value)
SELECT " & Mnth & ", " & Yr & ", Account, 0 FROM Accounts"

Mnth & Yr are the form values. If you want to only add new rows when a row doesn't exist, join the table holding the values with a LEFT join.
 
Thank you for your response, but I am not an access guru by any means. I have a form with the Month and Year, and a subform for the account and amount.

What or where do I need to insert the code you gave me?

Thank you in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top